:root {
    --bg: #090d13;
    --panel: #111822;
    --panel-soft: #1a2230;
    --card: #0d141f;
    --text: #e8edf5;
    --muted: #9aa7b6;
    --accent: #2f81f7;
    --accent-2: #1f6feb;
    --border: #2e3847;
    --ok: #2ea043;
    --warn: #c69026;
    --border: #2e3847ab;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-shell {
    display: grid;
    grid-template-columns: var(--left-col-width, 400px) 8px minmax(420px, 1fr) 8px var(--right-col-width, 400px);
    height: calc(100vh - 24px);
}

.panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

section.panel.center-column {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.col-resizer {
    cursor: col-resize;
    background: linear-gradient(180deg, #1a2230 0, #121924 100%);
    position: relative;
}

.col-resizer::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 46px;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    background: #3a4a61;
}

.col-resizer:hover::after {
    background: var(--accent);
}

.section-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    color: #dce6f2;
}

.hidden-input,
.hidden-canvas {
    display: none;
}

.left-column {
    height: 100%;
    cursor: pointer;
    position: relative;
    padding-bottom: 56px;
}

.left-column.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(47, 129, 247, 0.45) inset;
}

.drop-zone {
    flex: 1;
    min-height: 220px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 12px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

svg.big-icons {
    width: 60px;
    height: 60px;
    opacity: .5;
    transition: opacity 0.2s ease;
}

.left-column:hover svg.big-icons,
.right-column:hover svg.big-icons {
    opacity: 1;
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: linear-gradient(180deg, #172336 0, #111d2f 100%);
}

.drop-zone p {
    margin: 0;
    font-weight: 600;
}

.drop-zone small {
    color: var(--muted);
}

button {
    border: 0;
    background: #20243a;
    color: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    cursor: pointer;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.video-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #374151 #17202e;
}

.video-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 8px;
    cursor: pointer;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 100px;
}

.video-item:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(47, 129, 247, 0.3) inset;
}

.video-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(47, 129, 247, 0.3) inset;
}

.video-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(12, 17, 26, 0.75);
    color: #f2f5fb;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.video-remove svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.video-item:hover .video-remove {
    opacity: 1;
    pointer-events: auto;
}

.video-item img {
    width: 150px;
    aspect-ratio: 16/9;
    object-fit: contain;
    background: #02050a;
    border: 1px solid #202938;
}

.video-meta {
    min-width: 0;
}

.video-meta strong {
    display: block;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-meta span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.75rem;
}

.status-tag {
    margin-top: 4px;
    font-size: 0.73rem;
    color: #d4dde7;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.status-row .status-tag {
    margin-top: 0;
}

.status-ready {
    color: var(--ok);
}

.status-working {
    color: var(--warn);
}

.status-selected {
    color: var(--ok);
}

.status-unselected {
    color: var(--muted);
}

.video-wrap.large {
    background: #05090e;
    border: 1px solid var(--border);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    position: relative;
}

#videoPreview {
    width: 100%;
    height: 100%;
    display: block;
}

.video-overlay-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 66px;
    height: 66px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(5, 9, 14, 0.56);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    padding: 0;
    z-index: 2;
}

.video-overlay-btn svg {
    width: 32px;
    height: 32px;
    fill: #f4f8ff;
}

.videobtns {
    padding: 10px;
}


/* Keep control in DOM for custom logic, but hide from UI */

.video-overlay-btn {
    display: none !important;
}

.player-meta {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.8rem;
}

#playerVideoName {
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#timeline {
    margin-top: 8px;
    width: 100%;
}

.control-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 3px;
    justify-content: center;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #374151 #17202e;
}

.icon-btn {
    min-width: 42px;
    width: 50px;
    height: 50px;
    border-radius: 999px;
    padding: 0;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.icon-btn svg {
    width: 30px;
    height: 30px;
    fill: #f3f8ff;
}

.icon-btn-capture {
    width: 60px;
    height: 60px;
    background: #5c6285;
}

button.icon-btn:hover {
    background: #3F51B5;
}

.status {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    min-height: 18px;
    text-align: center;
}

.center-actions-row {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.center-action-btn {
    flex: 1;
    padding: 9px 10px;
    background: #2b3350;
    font-weight: 600;
}

.center-action-btn:hover {
    background: #3a4a7a;
}

.batch-download-row {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 4;
}

.batch-download-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
    background: #2b3350;
}

.batch-download-btn:not(:disabled):hover {
    background: #3a4a7a;
}

.right-column {
    min-height: 0;
    position: relative;
    padding-bottom: 56px;
}

.thumb-list {
    flex: 1;
    overflow: auto;
    gap: 8px;
    padding: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #374151 #17202e;
}

.thumb-list.view-1 {
    display: flex;
    flex-direction: column;
}

.thumb-list.view-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
}

.thumb-list.view-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
}

.right-download-row {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 4;
}

.right-download-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
    background: #2b3350;
}

.right-download-btn:not(:disabled):hover {
    background: #3a4a7a;
}

.thumb-list.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
}

.thumb-card {
    border: 2px solid;
    border-color: transparent;
    width: 100%;
    flex: 0 0 auto;
    position: relative;
    background: #0b111a;
    cursor: pointer;
    border-radius: 4px;
}

.thumb-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(47, 129, 247, 0.3) inset;
}

.thumb-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(47, 129, 247, 0.3) inset;
}

.thumb-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    display: block;
}

.thumb-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(12, 17, 26, 0.75);
    color: #f2f5fb;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.thumb-remove svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.thumb-remove:hover,
.video-remove:hover {
    background: #ff006293;
}

.thumb-card:hover .thumb-remove {
    opacity: 1;
    pointer-events: auto;
}

.thumb-card a {
    color: #8ec3ff;
    text-decoration: none;
}

.hidden {
    display: none;
}

.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.settings-modal.hidden {
    display: none;
}

.settings-card {
    width: min(560px, 100%);
    background: #111822;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
}

.settings-card h3 {
    margin: 0 0 12px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.settings-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--muted);
}

.settings-grid input,
.settings-grid select {
    background: #0f1520;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
}

.settings-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 640px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1300px) {
    .app-shell {
        grid-template-columns: var(--left-col-width, 240px) 8px minmax(420px, 1fr) 8px var(--right-col-width, 300px);
    }
}

@media (max-width: 1020px) {
    .app-shell {
        height: auto;
        grid-template-columns: 1fr;
    }
    .col-resizer {
        display: none;
    }
    .left-column,
    .right-column {
        max-height: 320px;
    }
}