:root {
    color-scheme: light;
    --aividz-bg: #edf0f4;
    --aividz-soft: #6b7280;
    --aividz-muted: #4b5563;
    --aividz-line: #e5e7eb;
    --aividz-accent: #2563eb;
    --aividz-green: #0f766e;
    --aividz-red: #dc2626;
    --aividz-yellow: #b7791f;
    --bs-primary-hover: #0a58ca;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.875rem;
    line-height: 1.42;
    background: var(--aividz-bg);
}

a {
    text-decoration: none;
}

h1,
.h1 {
    font-size: 1.75rem;
    line-height: 1.15;
}

h2,
.h2 {
    font-size: 1.2rem;
    line-height: 1.2;
}

h3,
.h3 {
    font-size: 1rem;
    line-height: 1.25;
}

h4,
.h4 {
    font-size: 0.9rem;
    line-height: 1.25;
}

.display-5 {
    font-size: 2rem;
    line-height: 1.1;
}

.lead {
    font-size: 0.95rem;
}

.btn {
    font-size: 0.875rem;
}

.btn-lg {
    font-size: 0.95rem;
}

.form-control,
.form-select,
.form-label,
.dropdown-menu,
.alert,
.table,
.list-group-item {
    font-size: 0.875rem;
}

.badge,
.small,
small {
    font-size: 0.75rem;
}

.fs-3 {
    font-size: 1.45rem !important;
}

.fs-5 {
    font-size: 1.05rem !important;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-mark {
    display: grid;
    width: 2.625rem;
    height: 2.625rem;
    place-items: center;
    border-radius: var(--bs-border-radius);
    color: #ffffff;
    background: linear-gradient(135deg, var(--aividz-green), var(--aividz-accent));
    font-weight: 800;
}

.brand span:last-child {
    display: grid;
    line-height: 1.1;
}

.brand small,
.card-meta {
    color: var(--aividz-soft);
}

.app-container,
.site-shell {
    max-width: 1520px;
}

.lead {
    max-width: 740px;
    color: var(--aividz-muted);
}

.project-hero,
.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: 1.5rem;
    align-items: start;
}

.story-steps article {
    padding: 0.875rem;
    border-radius: var(--bs-border-radius);
    background: #f8fafc;
}

.story-steps span,
.timeline span {
    color: var(--aividz-accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.story-steps .job-asset-name {
    margin: 0.2rem 0 0;
    color: var(--aividz-muted);
    font-size: 0.78rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.section-grid {
    display: grid;
    gap: 0.875rem;
    margin: 1.75rem 0;
}

.section-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stack,
.form-stack,
.inline-form,
.card-list,
.story-steps {
    display: grid;
    gap: 0.875rem;
}

.inline-form {
    grid-template-columns: minmax(160px, 1fr) auto;
    align-items: end;
    margin-top: 0.75rem;
}

.section-heading {
    display: grid;
    gap: 0.125rem;
    margin: 1.875rem 0 0.875rem;
}

.card > :last-child,
.card-body > :last-child,
.story-steps article > :last-child,
.transcript-block > :last-child,
.asset-job-monitor > :last-child,
.diagnostic-output > :last-child {
    margin-bottom: 0;
}

.project-actions {
    margin-top: 1rem;
}

.project-hero-clean,
.upload-layout {
    grid-template-columns: 1fr;
}

.sidebar-stack,
.export-card {
    display: grid;
    gap: 0.875rem;
    align-content: start;
}

.video-card {
    display: grid;
    grid-template-columns: 2.35rem minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
    align-content: stretch;
    transition: box-shadow 160ms ease, transform 180ms ease;
    will-change: transform;
}

.video-card-main {
    display: grid;
    gap: 0.875rem;
    min-width: 0;
    padding: 1rem;
}

.video-sort-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.25rem;
    background: #f2f4f7;
}

.video-sort-controls .btn {
    width: 1.55rem;
    height: 1.55rem;
    padding: 0;
    font-size: 0.72rem;
    line-height: 1;
}

.video-card.is-dragging {
    opacity: 0.96;
    box-shadow: 0 1.25rem 2.5rem rgb(15 23 42 / 0.2) !important;
}

.video-card.is-drag-over {
    outline: 2px solid rgba(37, 99, 235, 0.24);
    outline-offset: 3px;
}

.video-card.is-sort-dragging {
    position: fixed !important;
    z-index: 1080;
    pointer-events: none;
    transform: translate3d(0, 0, 0) rotate(0.2deg);
}

.video-sort-placeholder {
    border: 1px dashed rgb(37 99 235 / 0.35);
    border-radius: var(--bs-border-radius);
    background: rgb(37 99 235 / 0.06);
    transition: height 160ms ease, margin 160ms ease;
}

.video-drag-handle {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.video-drag-handle:active {
    cursor: grabbing;
}

.is-video-sorting,
.is-video-sorting * {
    cursor: grabbing !important;
}

.music-card {
    margin-bottom: 0.375rem;
}

.audio-preview-link {
    padding: 0;
    border: 0;
    color: var(--bs-link-color);
    background: transparent;
    font: inherit;
    font-weight: 400;
    text-decoration: none;
}

.audio-preview-link:hover,
.audio-preview-link:focus-visible {
    color: var(--bs-primary);
    text-decoration: none;
}

.project-list-card {
    gap: 0.5rem;
}

.project-title-link {
    font-size: 1.12rem;
    font-weight: 700;
}

#audioPreviewModal {
    --plyr-color-main: var(--bs-primary);
}

#audioPreviewModal .plyr {
    border-radius: var(--bs-border-radius);
}

.upload-card-wide {
    max-width: 1320px;
}

.upload-form,
.upload-section {
    display: grid;
    gap: 0.625rem;
}

.upload-form {
    gap: 0.75rem;
}

.upload-form.is-uploading .upload-zone {
    opacity: 0.62;
    cursor: progress;
}

.upload-form.is-uploading .selected-file-row button,
.upload-form.is-uploading [data-use-existing-music] {
    opacity: 0.58;
    cursor: not-allowed;
}

.upload-zone {
    display: grid;
    min-height: 188px;
    gap: 0.5rem;
    place-items: center;
    padding: 2rem 1.5rem;
    border: 1px dashed #cbd5e1;
    border-radius: var(--bs-border-radius);
    background: #eff6ff;
    text-align: center;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.upload-zone:hover,
.upload-zone.is-dragover {
    border-color: var(--aividz-accent);
    background: #dbeafe;
    box-shadow: 0 0.75rem 1.875rem rgba(37, 99, 235, 0.08);
}

.upload-zone[data-selected]:not([data-selected=""]) {
    border-color: var(--aividz-green);
    background: #ecfdf5;
}

.upload-zone span {
    font-weight: 800;
}

.upload-zone small {
    color: var(--aividz-muted);
}

.upload-zone input[type="file"] {
    position: fixed;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.selected-file-list {
    display: grid;
    gap: 0.5rem;
}

.selected-file-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--bs-border-radius);
    background: #f3f4f6;
    color: var(--aividz-muted);
}

.existing-music-list {
    display: grid;
    gap: 0.25rem;
    margin-top: 0;
    color: var(--aividz-muted);
}

.existing-music-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.existing-music-item.selected {
    color: var(--bs-body-color);
    font-weight: 700;
}

.upload-progress-wrap {
    padding: 0.875rem;
    border-radius: var(--bs-border-radius);
    background: #f8fafc;
}

.progress {
    min-width: 110px;
    height: 0.8rem;
    background: #e5e7eb;
}

.progress-bar {
    background-color: var(--aividz-accent);
    font-size: 0.68rem;
    font-weight: 700;
}

.video-card-head {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
    gap: 0.875rem;
    align-items: start;
}

.video-preview-trigger {
    position: relative;
    display: block;
    overflow: hidden;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: var(--bs-border-radius);
    background: transparent;
    text-align: inherit;
}

.video-preview-trigger:not(:disabled) {
    cursor: pointer;
}

.video-preview-trigger:disabled {
    cursor: default;
}

.video-preview-trigger:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.28);
    outline-offset: 3px;
}

.video-thumbnail {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: inherit;
    background: #eef2f7;
}

.video-thumbnail.placeholder {
    display: grid;
    place-items: center;
    color: var(--aividz-muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.video-preview-frame-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
}

.video-preview-frame {
    position: absolute;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
    transition: none !important;
}

.video-preview-frame.is-active {
    display: block;
}

.video-preview-loader {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 4;
    display: none;
    height: 3px;
    overflow: hidden;
    border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
    background: rgba(13, 110, 253, 0.16);
    pointer-events: none;
}

.video-preview-loader::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -42%;
    width: 42%;
    background: linear-gradient(90deg, transparent, var(--bs-primary), transparent);
    content: "";
    animation: thumbnail-preview-loader 1.05s ease-in-out infinite;
}

.video-preview-trigger.is-preview-loading .video-preview-loader {
    display: block;
}

@keyframes thumbnail-preview-loader {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(340%);
    }
}

.video-preview-play {
    position: absolute;
    right: 0.625rem;
    bottom: 0.625rem;
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 999px;
    background: var(--bs-primary);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1;
    pointer-events: none;
    transition: background-color 160ms ease;
    z-index: 3;
}

.video-preview-trigger:not(:disabled):hover .video-preview-play,
.video-preview-trigger:not(:disabled):focus-visible .video-preview-play {
    background: var(--bs-primary-hover, #0a58ca);
}

.video-preview-player {
    display: block;
    width: 100%;
    max-height: 78vh;
    border-radius: 0;
    background: #000;
}

#videoPreviewModal .modal-body {
    padding: 0;
}

#videoPreviewModal {
    --plyr-color-main: var(--bs-primary);
}

#videoPreviewModal .plyr {
    border-radius: 0;
}

#videoPreviewModal .plyr__video-wrapper {
    border-radius: 0;
}

.plyr-preview-timecode {
    display: inline-flex;
    align-items: center;
    color: #fff;
    font-size: 0.72rem;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: 0;
}

#videoPreviewModal .plyr,
#videoPreviewModal .plyr__video-wrapper {
    max-height: 78vh;
}

#videoPreviewModal .plyr:fullscreen,
#videoPreviewModal .plyr:-webkit-full-screen,
#videoPreviewModal .plyr.plyr--fullscreen-active,
#videoPreviewModal .plyr.plyr--fullscreen-fallback {
    display: flex !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: none !important;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 0;
}

#videoPreviewModal .plyr:fullscreen .plyr__video-wrapper,
#videoPreviewModal .plyr:-webkit-full-screen .plyr__video-wrapper,
#videoPreviewModal .plyr.plyr--fullscreen-active .plyr__video-wrapper,
#videoPreviewModal .plyr.plyr--fullscreen-fallback .plyr__video-wrapper {
    width: 100vw !important;
    height: 100vh !important;
    max-height: none !important;
}

#videoPreviewModal .plyr:fullscreen video,
#videoPreviewModal .plyr:-webkit-full-screen video,
#videoPreviewModal .plyr.plyr--fullscreen-active video,
#videoPreviewModal .plyr.plyr--fullscreen-fallback video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.video-trim-panel {
    padding: 1rem 1rem 1.125rem;
}

.video-trim-strip {
    position: relative;
    height: 5.25rem;
    overflow: hidden;
    border-radius: var(--bs-border-radius);
    background: #111827;
    user-select: none;
}

.video-trim-frames {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 100%;
}

.video-trim-frames img,
.video-trim-frame-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-trim-frame-placeholder {
    background: #1f2937;
}

.video-trim-selection {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    border-left: 2px solid var(--bs-primary);
    border-right: 2px solid var(--bs-primary);
    background: transparent;
    pointer-events: none;
}

.video-trim-strip::before,
.video-trim-strip::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 1;
    background: rgb(0 0 0 / 0.46);
    pointer-events: none;
}

.video-trim-strip::before {
    left: 0;
    width: var(--trim-left, 0%);
}

.video-trim-strip::after {
    right: 0;
    width: var(--trim-right, 0%);
}

.video-trim-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 4;
    width: 1.5rem;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent !important;
    transform: translateX(-50%);
    cursor: ew-resize;
}

.video-trim-marker::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    border-radius: 999px;
    background: var(--bs-primary);
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px rgb(255 255 255 / 0.3);
}

.video-trim-marker:focus-visible {
    outline: 2px solid rgb(13 110 253 / 0.35);
    outline-offset: -2px;
}

.subtle-delete-form {
    margin-top: 0.375rem;
}

.video-meta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-top: 0.25rem;
    color: var(--aividz-soft);
    font-size: 0.78rem;
}

.video-meta-actions .subtle-delete-form {
    margin: 0;
}

.text-link,
.subtle-delete-form button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--aividz-accent);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.danger-link,
.subtle-delete-form button {
    color: #b91c1c;
    text-decoration: none;
}

.text-link:hover {
    color: #1d4ed8;
    text-decoration: none;
}

.subtle-delete-form button:hover {
    color: #7f1d1d;
    text-decoration: none;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.78rem;
}

.card-meta.large {
    margin-top: 1rem;
}

.card-meta span {
    display: inline-flex;
    align-items: center;
    min-height: 1.875rem;
    padding: 0.3125rem 0.5625rem;
    border-radius: var(--bs-border-radius);
    background: #f3f4f6;
}

.video-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

.video-details {
    margin: 0;
}

.video-card-info .video-details {
    margin-top: 10px;
}

.video-details summary {
    cursor: pointer;
    color: var(--aividz-accent);
    font-weight: 700;
}

.video-details-body {
    display: grid;
    gap: 0.875rem;
    padding-top: 0.875rem;
}

.lut-form {
    grid-template-columns: minmax(180px, 280px);
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    gap: 0.5rem;
}

.analysis-grid span {
    display: grid;
    gap: 0.125rem;
    min-height: 54px;
    padding: 0.5625rem 0.625rem;
    border-radius: var(--bs-border-radius);
    color: var(--aividz-soft);
    background: #f9fafb;
    font-size: 0.75rem;
}

.analysis-grid strong {
    color: var(--bs-body-color);
    font-size: 0.7rem;
}

.asset-job-monitor {
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: var(--bs-border-radius);
    background: #eff6ff;
}

.asset-progress-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.625rem;
}

.asset-job-monitor p {
    margin: 0;
}

.export-card [data-render-output] {
    display: grid;
    gap: 0.75rem;
}

.export-card [data-render-output].d-none {
    display: none !important;
}

.transcript-block {
    display: grid;
    gap: 0.5rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--aividz-line);
}

.transcript-block h4 {
    margin: 0;
    font-size: 0.9rem;
}

.transcript-meta-hero {
    margin-top: -0.75rem;
}

.transcript-language-field {
    max-width: 220px;
}

.transcript-language-form {
    max-width: 220px;
}

.segment-preview,
.segment-list {
    display: grid;
    gap: 0.625rem;
}

.segment-preview {
    margin: 0.375rem 0;
}

.segment-preview article,
.segment-row {
    padding: 0.75rem;
    border-left: 3px solid var(--aividz-accent);
    border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) 0;
    background: #f8fafc;
}

.segment-preview strong,
.segment-row strong {
    color: var(--aividz-accent);
    font-size: 0.76rem;
}

.segment-time-editor {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    color: var(--aividz-accent);
    font-size: 0.76rem;
    font-weight: 700;
}

[contenteditable="true"] {
    border-radius: var(--bs-border-radius);
    outline: 0;
}

[contenteditable="true"]:focus {
    background: #eff6ff;
    box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.16);
}

.segment-preview p,
.segment-row p {
    margin: 0.375rem 0 0;
}

.job-mini-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.875rem;
}

.job-mini-list div {
    display: flex;
    justify-content: space-between;
    gap: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--aividz-line);
}

.status-uploaded,
.status-analyzing,
.status-planning,
.status-rendering,
.status-running {
    color: var(--aividz-accent);
}

.status-completed {
    color: var(--aividz-green);
}

.status-failed {
    color: var(--aividz-red);
}

.status-draft,
.status-pending,
.status-queued {
    color: var(--aividz-yellow);
}

.completed-jobs {
    margin-top: 1.125rem;
}

.completed-jobs summary,
.video-details summary {
    cursor: pointer;
    color: var(--aividz-accent);
    font-weight: 700;
}

.error-text {
    color: #b91c1c;
}

.form-message {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--aividz-green);
    font-size: 0.76rem;
    font-weight: 700;
}

.transcript-text {
    margin: 1rem 0 0;
    padding: 1rem;
    border-radius: var(--bs-border-radius);
    color: var(--bs-body-color);
    background: #f9fafb;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

.copy-source {
    display: none;
}

.timeline {
    position: relative;
    display: grid;
    gap: 1rem;
    margin: 1.75rem 0;
}

.timeline::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 21px;
    width: 2px;
    content: "";
    background: linear-gradient(var(--aividz-green), #dc6b4f);
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 1rem;
}

.timeline-index {
    z-index: 1;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: var(--bs-border-radius);
    color: #ffffff;
    background: var(--aividz-green);
    font-weight: 800;
}

.timeline .card header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.625rem;
}

.timeline .card dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0.875rem 0 0;
}

.timeline .card dt {
    color: var(--aividz-soft);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.timeline .card dd {
    margin: 0.25rem 0 0;
    color: #374151;
}

.status-row-running {
    background: #eff6ff;
}

.status-row-completed {
    background: #ecfdf5;
}

.status-row-failed {
    background: #fef2f2;
}

.diagnostic-output {
    overflow-x: auto;
    max-height: 260px;
    margin: 0.875rem 0 0;
    padding: 0.875rem;
    border-radius: var(--bs-border-radius);
    color: #1f2937;
    background: #f9fafb;
    white-space: pre-wrap;
}

@media (max-width: 900px) {
    .project-hero,
    .content-grid,
    .section-grid.two,
    .section-grid.three,
    .section-grid.four,
    .timeline .card dl,
    .inline-form,
    .video-card-head {
        grid-template-columns: 1fr;
    }

    .video-thumbnail {
        max-width: 320px;
    }
}

@media (max-width: 620px) {
    .site-shell {
        padding-top: 2.25rem;
        padding-bottom: 3.375rem;
    }

    .timeline .card header,
    .job-mini-list div {
        display: grid;
    }
}
