.studio-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    padding: 10px 20px 16px;
}

.workspace-card,
.preview-card {
    padding: 16px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

/* CABECERA DEL ÁREA DE TRABAJO */

.card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 12px;
}

.card-heading h1,
.preview-card h2 {
    margin: 0;
    color: #182033;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
}

.card-heading h1 {
    flex-shrink: 0;
}

/* BARRA DE ACCIONES */

.recording-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.capture-actions,
.recording-result-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recording-actions .primary-button,
.recording-actions .secondary-button,
.recording-actions #downloadButton,
.recording-actions #trimButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 38px;
    padding: 0 14px;

    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}

.recording-result-actions {
    opacity: 0;
    transform: translateY(4px);

    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.recording-result-actions.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* SELECTOR DE FORMATO */

.format-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 260px;
}

.audio-selector {
    flex: 0 1 260px;
}

.capture-actions {
    flex: 0 0 auto;
}

.format-selector label {
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.format-selector select {
    width: 100%;
    max-width: 100%;
    min-height: 40px;
    padding: 0 36px 0 12px;

    border: 1px solid #cbd5e1;
    border-radius: 10px;

    background-color: #ffffff;
    color: #182033;

    font-family: inherit;
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
    outline: none;

    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.format-selector select:hover {
    border-color: #94a3b8;
}

.format-selector select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* TEMPORIZADOR */

.recording-timer {
    min-width: 54px;
    color: #dc2626;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

/* ÁREA DE VIDEO */

.video-stage {
    position: relative;
    display: grid;
    place-items: center;

    min-height: 420px;
    max-height: 64vh;

    overflow: hidden;
    border-radius: 12px;

    background: #111827;
    color: #cbd5e1;
}

#sourceVideo {
    display: block;
    max-width: 100%;
    max-height: 64vh;
}

/* CÁMARA VIRTUAL */

.virtual-camera {
    position: absolute;

    width: 180px;
    aspect-ratio: 9 / 16;

    border: 3px solid #ffffff;
    border-radius: 8px;

    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.25),
        0 4px 18px rgba(0, 0, 0, 0.3);

    background:
        radial-gradient(
            circle at 7px 7px,
            #2563eb 0 4px,
            #ffffff 4.5px 7px,
            transparent 7.5px
        )
        left top / 14px 14px no-repeat,

        radial-gradient(
            circle at 7px 7px,
            #2563eb 0 4px,
            #ffffff 4.5px 7px,
            transparent 7.5px
        )
        right top / 14px 14px no-repeat,

        radial-gradient(
            circle at 7px 7px,
            #2563eb 0 4px,
            #ffffff 4.5px 7px,
            transparent 7.5px
        )
        left bottom / 14px 14px no-repeat,

        radial-gradient(
            circle at 7px 7px,
            #2563eb 0 4px,
            #ffffff 4.5px 7px,
            transparent 7.5px
        )
        right bottom / 14px 14px no-repeat;

    cursor: grab;
    touch-action: none;
    user-select: none;
}

.virtual-camera:hover {
    border-color: #dbeafe;
}

.virtual-camera:active {
    cursor: grabbing;
    border-color: #93c5fd;
}

/* VISTA PREVIA */

.preview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-card h2 {
    align-self: stretch;
    margin-bottom: 0;
}

#previewCanvas {
    display: block;

    width: auto;
    height: min(58vh, 560px);
    max-width: 100%;

    aspect-ratio: 9 / 16;

    border-radius: 12px;
    background: #111827;
}

/* PANEL DE ATAJOS */

.shortcuts-panel {
    position: fixed;
    top: 70px;
    right: 24px;
    z-index: 1000;

    width: 270px;
    padding: 16px;

    border-radius: 12px;
    background: #ffffff;

    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

/* PANTALLAS MEDIANAS */

@media (max-width: 1180px) {
    .studio-layout {
        grid-template-columns: minmax(0, 1fr) 280px;
    }

    .card-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .recording-actions {
        width: 100%;
        justify-content: flex-start;
    }

    #previewCanvas {
        height: min(54vh, 500px);
    }
}

/* TABLET Y MÓVIL */

@media (max-width: 900px) {
    .studio-layout {
        grid-template-columns: 1fr;
        padding: 10px 12px;
    }

    .card-heading h1,
    .preview-card h2 {
        font-size: 22px;
    }

    .recording-actions {
        flex-wrap: wrap;
    }

    .format-selector {
        flex: 1 1 100%;
        width: 100%;
    }

    .format-selector select {
        flex: 1;
        width: 100%;
    }

    .preview-card {
        width: 100%;
        max-width: 360px;
        margin: auto;
    }

    #previewCanvas {
        width: 100%;
        height: auto;
    }
}

/* MÓVILES PEQUEÑOS */

@media (max-width: 560px) {
    .workspace-card,
    .preview-card {
        padding: 12px;
        border-radius: 14px;
    }

    .format-selector {
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
    }

    .format-selector select {
        width: 100%;
    }

    .recording-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .capture-actions,
    .recording-result-actions {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .recording-actions .primary-button,
    .recording-actions .secondary-button,
    .recording-actions #downloadButton,
    .recording-actions #trimButton {
        width: 100%;
    }

    .recording-timer {
        width: 100%;
        padding: 4px 0;
    }

    .video-stage {
        min-height: 320px;
    }
}

/* =========================================================
   CORTADOR DE VIDEO
   ========================================================= */

.trim-header {
    gap: 20px;
}

.trim-back-button {
    text-decoration: none;
}

.trim-layout {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 20px 24px;
}

.trim-card {
    width: 100%;
}

.trim-card-heading {
    align-items: flex-start;
}

.trim-description {
    max-width: 680px;
    margin: 6px 0 0;
    color: #64748b;
    font-size: 15px;
    line-height: 1.5;
}

/* REPRODUCTOR */

.trim-video-stage {
    position: relative;
    display: grid;
    place-items: center;

    width: 100%;
    min-height: 440px;
    max-height: 62vh;

    overflow: hidden;
    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.04),
            rgba(255, 255, 255, 0)
        ),
        #111827;
}

.trim-video {
    display: none;
    width: 100%;
    max-width: 100%;
    max-height: 62vh;
    object-fit: contain;
    background: #000000;
}

.trim-video.is-visible {
    display: block;
}

.trim-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    min-height: 220px;
    padding: 30px;

    color: #e2e8f0;
    text-align: center;
}

.trim-empty-state strong {
    color: #ffffff;
    font-size: 18px;
}

.trim-empty-state p {
    max-width: 420px;
    margin: 8px 0 0;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.5;
}

/* INFORMACIÓN DE TIEMPO */

.trim-controls {
    margin-top: 22px;
}

.trim-time-information {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
    gap: 20px;
    margin-bottom: 14px;
}

.trim-time-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trim-time-item span {
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.trim-time-item strong {
    color: #182033;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.trim-duration-item {
    align-items: center;
    text-align: center;
}

.trim-time-item-end {
    align-items: flex-end;
    text-align: right;
}

/* LÍNEA DE TIEMPO */

.trim-timeline {
    padding: 18px 12px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #f8fafc;
    user-select: none;
}

.trim-timeline-track {
    position: relative;
    display: flex;
    align-items: stretch;

    width: 100%;
    height: 22px;

    border-radius: 8px;
    background: #cbd5e1;
}

.trim-removed-area {
    position: absolute;
    top: 0;
    bottom: 0;

    background: rgba(15, 23, 42, 0.58);
}

.trim-removed-before {
    left: 0;
    width: 0;
    border-radius: 8px 0 0 8px;
}

.trim-removed-after {
    right: 0;
    width: 0;
    border-radius: 0 8px 8px 0;
}

.trim-selected-area {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;

    border-radius: 8px;
    background: #2563eb;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

/* TIRADORES */

.trim-handle {
    position: absolute;
    top: 50%;
    z-index: 3;

    width: 24px;
    height: 42px;
    padding: 0;

    border: 3px solid #ffffff;
    border-radius: 8px;
    background: #2563eb;

    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);

    cursor: grab;
    transform: translate(-50%, -50%);
    touch-action: none;
}

.trim-handle:hover {
    background: #1d4ed8;
}

.trim-handle:active {
    cursor: grabbing;
}

.trim-handle > span:first-child {
    position: absolute;
    top: 50%;
    left: 50%;

    width: 4px;
    height: 16px;

    border-left: 1px solid rgba(255, 255, 255, 0.85);
    border-right: 1px solid rgba(255, 255, 255, 0.85);

    transform: translate(-50%, -50%);
}

.trim-start-handle {
    left: 0;
}

.trim-end-handle {
    left: 100%;
}

.trim-help-text {
    margin: 10px 0 0;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

/* ACCIONES */

.trim-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.trim-actions a {
    text-decoration: none;
}

.trim-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* TABLET Y MÓVIL */

@media (max-width: 900px) {
    .trim-layout {
        padding: 10px 12px 20px;
    }

    .trim-video-stage {
        min-height: 360px;
    }
}

/* MÓVILES PEQUEÑOS */

@media (max-width: 560px) {
    .trim-header {
        align-items: stretch;
        flex-direction: column;
    }

    .trim-back-button {
        width: 100%;
        text-align: center;
    }

    .trim-video-stage {
        min-height: 280px;
    }

    .trim-time-information {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .trim-duration-item {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .trim-time-item-end {
        align-items: flex-end;
    }

    .trim-timeline {
        padding-right: 14px;
        padding-left: 14px;
    }

    .trim-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .trim-actions .primary-button,
    .trim-actions .secondary-button {
        width: 100%;
        text-align: center;
    }
}
