/* MagicSub Premium Dark Theme */
:root {
    /* Palette */
    --bg-app: #0f0f11;
    --bg-panel: #18181b;
    --bg-panel-border: #27272a;
    --bg-input: #232326;

    --primary: #8b5cf6;
    /* Violet */
    --primary-hover: #7c3aed;
    --secondary: #3f3f46;
    --secondary-hover: #52525b;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --muted: #a1a1aa;
    --dim: #52525b;

    --text-main: #f4f4f5;
    --text-muted: #d4d4d8;
    --bg: var(--bg-app);
    --text: var(--text-main);

    /* Layout */
    --header-height: 60px;
    --sidebar-width: 380px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    /* App-like feel */
    height: 100vh;
}

/* --- Utilities --- */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-4 {
    gap: 1rem;
}

.p-4 {
    padding: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}

.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xl {
    font-size: 1.25rem;
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.text-muted {
    color: var(--muted);
}

.text-dim {
    color: var(--dim);
}

.text-primary {
    color: var(--primary);
}

.text-white {
    color: #fff;
}

.text-warning {
    color: var(--warning);
}

.text-success {
    color: var(--success);
}

.rounded {
    border-radius: 8px;
}

.bg-glass {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
}

.border {
    border: 1px solid var(--bg-panel-border);
}

/* --- Components --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
    text-decoration: none;
    color: #fff;
}

.btn-primary {
    background-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Inputs / Selects */
input[type="text"],
input[type="number"],
textarea,
select {
    background-color: var(--bg-input);
    border: 1px solid var(--bg-panel-border);
    color: var(--text-main);
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

textarea {
    resize: vertical;
}

/* --- Layout Specifics --- */

/* Index Page Hero */
.hero-container {
    width: 100%;
    max-width: 480px;
    text-align: center;
    margin-top: -10vh;
    /* Visual centering adjustment */
}

.brand {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--bg-panel-border);
    background: rgba(255, 255, 255, 0.01);
    border-radius: 12px;
    padding: 3rem 1rem;
    position: relative;
    /* For overlay input */
    transition: all 0.3s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
    /* primary with opacity */
}

.file-input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* App Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--bg-panel-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: space-between;
}

.tagline {
    margin-left: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.download-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.download-menu {
    position: relative;
}

.download-menu summary {
    list-style: none;
}

.download-menu summary::-webkit-details-marker {
    display: none;
}

.download-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 40;
    display: grid;
    gap: 4px;
    min-width: 210px;
    padding: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--bg-panel-border);
    border-radius: 8px;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.18);
}

.download-menu-panel button {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    padding: 9px 10px;
    text-align: left;
}

.download-menu-panel button:hover {
    background: rgba(37, 99, 235, 0.09);
}

/* Workspace (2-column layout) */
.workspace {
    display: flex;
    flex-direction: row;
    /* Explicitly row */
    height: calc(100vh - var(--header-height));
    width: 100vw;
    overflow: hidden;
}

.ws-main {
    flex: 1;
    min-width: 0;
    /* Crucial for flex item scrolling/sizing */
    display: flex;
    flex-direction: column;
    background-color: #000;
    position: relative;
    overflow: hidden;
    /* Ensure video doesn't spill */
}

.ws-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    /* Prevent shrinking */
    background-color: var(--bg-panel);
    border-left: 1px solid var(--bg-panel-border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    z-index: 10;
    /* Ensure it stays on top if overlapping happens */
}

.current-subtitle-editor {
    flex-shrink: 0;
    display: grid;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--bg-panel-border);
}

.current-editor-head,
.current-editor-actions,
.current-editor-state,
.subtitle-list-head {
    display: flex;
    align-items: center;
}

.current-editor-head {
    justify-content: space-between;
    gap: 12px;
}

.current-editor-state {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.current-time-range {
    margin-top: 2px;
    color: var(--text-main);
    font-weight: 700;
}

.current-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.field-caption {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.current-edit-field {
    display: block;
}

.current-edit-field textarea {
    width: 100%;
    min-height: 86px;
    max-height: 180px;
    overflow-y: auto;
    line-height: 1.55;
}

.subtitle-time-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.subtitle-time-grid label {
    display: grid;
    min-width: 0;
}

.subtitle-time-grid input {
    width: 100%;
    height: 36px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.current-editor-actions {
    gap: 8px;
    flex-wrap: wrap;
}

.btn.active {
    background: var(--primary);
    color: #ffffff;
}

.subtitle-list-head {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

/* Video Player */
.player-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
    position: relative;
    width: 100%;
    /* Ensure it fills ws-main width */
}

video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Correct aspect ratio handling */
    box-shadow: none;
    /* Shadow might look weird if it fills screen */
}

/* Timeline */
.timeline-container {
    height: 136px;
    background-color: #121212;
    border-top: 1px solid var(--bg-panel-border);
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    user-select: none;
}

/* Scrollbar needed for timeline */
.timeline-container::-webkit-scrollbar {
    height: 8px;
}

.timeline-container::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.time-ruler {
    position: sticky;
    left: 10px;
    top: 5px;
    z-index: 10;
    font-size: 0.7rem;
    color: var(--muted);
    pointer-events: none;
}

.timeline-track {
    position: relative;
    height: 86px;
    margin-top: 28px;
    background: #1a1a1a;
    min-width: 100%;
    /* Expands via JS */
}

.timeline-waveform-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.95;
    pointer-events: none;
    z-index: 1;
}

.timeline-cursor {
    position: absolute;
    top: -28px;
    /* Overlap ruler area */
    bottom: 0;
    width: 2px;
    background-color: #ef4444;
    z-index: 20;
    cursor: ew-resize;
    pointer-events: auto;
    touch-action: none;
}

.timeline-cursor::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 18px;
}

.timeline-block {
    position: absolute;
    top: 42px;
    height: 34px;
    background: rgba(139, 92, 246, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.6);
    border-radius: 4px;
    color: #fff;
    font-size: 0.7rem;
    padding: 4px;
    overflow: hidden;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 4;
}

.timeline-block-label {
    display: block;
    overflow: hidden;
    pointer-events: none;
    text-overflow: ellipsis;
}

.timeline-handle {
    display: none;
    position: absolute;
    top: -5px;
    bottom: -5px;
    width: 14px;
    border: 2px solid #ffffff;
    background: #1d4ed8;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
    z-index: 30;
}

.timeline-handle-start {
    left: -7px;
    border-radius: 8px 3px 3px 8px;
    cursor: ew-resize;
}

.timeline-handle-end {
    right: -7px;
    border-radius: 3px 8px 8px 3px;
    cursor: ew-resize;
}

.timeline-block:hover {
    background: rgba(139, 92, 246, 0.6);
    z-index: 5;
}

.timeline-block.active {
    background: var(--warning);
    color: #000;
    border-color: #f59e0b;
    z-index: 25;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.timeline-block.active .timeline-handle {
    display: block;
}

/* Subtitle List */
.sub-table-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
    /* Space for scrollbar */
}

.sub-table-container::-webkit-scrollbar {
    width: 6px;
}

.sub-table-container::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.sub-row {
    width: 100%;
    display: flex;
    gap: 8px;
    padding: 8px;
    background: var(--bg-input);
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.1s;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.sub-row-content {
    min-width: 0;
}

.sub-preview {
    overflow: hidden;
    color: var(--text-main);
    font-size: 0.88rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-row-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-row:hover {
    background: #2a2a2d;
}

.sub-row.active {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.time-badge {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--muted);
    min-width: 45px;
    padding-top: 4px;
}

.sub-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    min-height: 20px;
}

.sub-textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

/* Loading Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading-box {
    text-align: center;
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--bg-panel-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Form Elements */
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

/* --- Added Missing Utilities & Components --- */

/* Misc Utilities from review.js */
.border-bg-panel-border {
    border-color: var(--bg-panel-border);
}

.border-l-2 {
    border-left-width: 2px;
    border-left-style: solid;
}

.border-dim {
    border-color: var(--dim);
}

.select-none {
    user-select: none;
    -webkit-user-select: none;
}

.cursor-pointer {
    cursor: pointer;
}

.flex-1 {
    flex: 1;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.overflow-hidden {
    overflow: hidden;
}

.z-10 {
    z-index: 10;
}

.z-20 {
    z-index: 20;
}

.opacity-0 {
    opacity: 0;
}

.disabled-field {
    opacity: 0.5;
    pointer-events: none;
}



/* Progress Bar (index.html) */
.progress-bar-container {
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-inner {
    background: var(--primary);
    transition: width 0.4s;
    height: 100%;
}

/* AWS workspace */
.aws-body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

.aws-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 84px auto 32px auto;
}

.aws-grid {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(280px, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.aws-panel {
    background: var(--bg-panel);
    border: 1px solid var(--bg-panel-border);
    border-radius: 8px;
    padding: 18px;
}

.aws-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.aws-panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.aws-panel-head h2 {
    font-size: 1rem;
    margin: 0;
}

.aws-form {
    display: grid;
    gap: 12px;
}

.aws-form label {
    display: grid;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.aws-form input {
    width: 100%;
    background: #111;
    border: 1px solid #333;
    color: var(--text);
    border-radius: 6px;
    padding: 10px 12px;
}

.aws-details {
    margin-top: 16px;
    border-top: 1px solid var(--bg-panel-border);
    padding-top: 14px;
}

.aws-details summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.aws-alert {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 8px;
    color: #fbbf24;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.aws-message {
    min-height: 22px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.aws-message.error {
    color: #f87171;
}

.aws-upload-zone {
    min-height: 160px;
    position: relative;
}

.aws-progress {
    width: 100%;
    height: 8px;
    background: #252525;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 14px;
}

.aws-progress div {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.25s ease;
}

.aws-jobs {
    display: grid;
    gap: 8px;
}

.aws-job-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    text-align: left;
    background: #171717;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    color: var(--text);
    padding: 12px;
    cursor: pointer;
}

.aws-job-row:hover,
.aws-job-row.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

.aws-job-status {
    display: grid;
    gap: 3px;
    text-align: right;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.aws-job-status strong {
    color: var(--text);
}

.aws-job-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 190px;
}

.aws-job-state {
    min-width: 48px;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: right;
}

.aws-selected-job {
    min-height: 0;
}

.aws-action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 820px) {
    .aws-shell {
        width: calc(100vw - 20px);
        margin-top: 96px;
    }

    .aws-grid {
        grid-template-columns: 1fr;
    }

    .aws-job-row {
        grid-template-columns: 1fr;
    }

    .aws-job-actions {
        justify-content: flex-start;
        min-width: 0;
        flex-wrap: wrap;
    }

    .aws-job-state {
        text-align: left;
    }

    .aws-job-status {
        text-align: left;
    }
}

/* AWS workspace refresh: clear, high-contrast production tool UI */
body.aws-body,
body.aws-review-body {
    --bg-app: #f5f7fb;
    --bg-panel: #ffffff;
    --bg-panel-border: #d8dee8;
    --bg-input: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #ffffff;
    --secondary-hover: #eef4ff;
    --success: #059669;
    --warning: #b45309;
    --danger: #dc2626;
    --muted: #667085;
    --dim: #98a2b3;
    --text-main: #111827;
    --text-muted: #475467;
    --bg: #f5f7fb;
    --text: #111827;
    background: var(--bg-app);
    color: var(--text-main);
}

body.aws-body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
}

body.aws-review-body {
    height: 100vh;
    overflow: hidden;
}

body.aws-body .app-header,
body.aws-review-body .app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 64px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--bg-panel-border);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    backdrop-filter: blur(12px);
}

body.aws-body .brand,
body.aws-review-body .brand {
    background: none;
    background-clip: border-box;
    -webkit-background-clip: border-box;
    -webkit-text-fill-color: currentColor;
    color: var(--text-main);
    font-size: 1.35rem;
    letter-spacing: 0;
}

body.aws-body .brand span,
body.aws-review-body .brand span {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--muted) !important;
}

.brand-link {
    color: inherit;
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: 18px;
    color: #475467;
    font-size: 0.85rem;
    font-weight: 700;
}

.site-nav a {
    color: inherit;
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--primary);
}

.app-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

body.aws-body .tagline,
body.aws-review-body .tagline {
    min-width: 0;
    color: var(--text-muted);
}

body.aws-body .btn,
body.aws-review-body .btn {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-weight: 700;
    line-height: 1;
}

body.aws-body .btn-primary,
body.aws-review-body .btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.24);
}

body.aws-body .btn-primary:hover,
body.aws-review-body .btn-primary:hover {
    background: var(--primary-hover);
}

body.aws-body .btn-secondary,
body.aws-review-body .btn-secondary,
body.aws-body .aws-select,
body.aws-review-body .aws-select {
    background: #ffffff;
    border-color: #cfd7e6;
    color: var(--text-main);
}

body.aws-body .btn-secondary:hover,
body.aws-review-body .btn-secondary:hover {
    background: var(--secondary-hover);
    border-color: #9bb7f0;
}

body.aws-body .btn:disabled,
body.aws-review-body .btn:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    box-shadow: none;
}

body.aws-body input,
body.aws-body textarea,
body.aws-body select,
body.aws-review-body input,
body.aws-review-body textarea,
body.aws-review-body select {
    background: #ffffff;
    border: 1px solid #cfd7e6;
    color: var(--text-main);
    border-radius: 7px;
    padding: 10px 12px;
}

body.aws-body textarea,
body.aws-review-body textarea {
    min-height: 120px;
    line-height: 1.5;
}

body.aws-body input:focus,
body.aws-body textarea:focus,
body.aws-body select:focus,
body.aws-review-body input:focus,
body.aws-review-body textarea:focus,
body.aws-review-body select:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--primary);
}

body.aws-body .aws-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 24px auto 48px auto;
}

.ad-layout {
    display: grid;
    grid-template-columns: 128px minmax(0, 1180px) 128px;
    gap: 16px;
    width: min(1484px, calc(100vw - 32px));
    margin: 24px auto 48px;
    align-items: start;
}

.ad-layout .aws-shell {
    width: 100%;
    margin: 0;
}

.ad-rail {
    min-width: 0;
    position: sticky;
    top: 84px;
}

body.aws-body .aws-grid {
    grid-template-columns: minmax(320px, 460px) minmax(320px, 1fr);
    gap: 18px;
    align-items: start;
}

.aws-market-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.aws-domain {
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 800;
}

.ad-slot {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #aab7c9;
    border-radius: 8px;
    background: #f8fafc;
    color: #667085;
    font-size: 0.82rem;
    font-weight: 800;
}

.ad-slot-rail {
    min-height: 560px;
    height: calc(100vh - 124px);
    max-height: 760px;
    padding: 18px 10px;
    text-align: center;
    line-height: 1.45;
}

.aws-option-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.aws-status-card {
    display: grid;
    gap: 5px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px 12px;
    color: #475467;
    font-size: 0.82rem;
    line-height: 1.4;
}

.aws-status-card strong {
    color: var(--text-main);
}

.aws-status-card.ready {
    border-color: #abd7c7;
    background: #f0fdf7;
}

.aws-status-card.blocked {
    border-color: #f1c9c9;
    background: #fff7f7;
}

.provider-row,
.aws-job-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.provider-help {
    color: #667085;
    font-size: 0.78rem;
}

.aws-job-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 8px;
}

.aws-job-meta span {
    border: 1px solid #d8dee8;
    border-radius: 999px;
    padding: 3px 8px;
    background: #f8fafc;
    color: #475467;
    font-size: 0.75rem;
    font-weight: 700;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    color: #667085;
    font-size: 0.78rem;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.site-footer a,
.privacy-section a,
.info-section a,
.faq-list a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.site-footer a:hover,
.privacy-section a:hover,
.info-section a:hover,
.faq-list a:hover {
    text-decoration: underline;
}

.privacy-shell {
    max-width: 860px;
}

.privacy-hero {
    padding: 18px 0 16px;
    border-bottom: 1px solid #d8dee8;
}

.privacy-hero h1 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 1.65rem;
}

.privacy-hero p,
.privacy-section p {
    color: #475467;
    line-height: 1.65;
}

.privacy-section {
    padding: 20px 0;
    border-bottom: 1px solid #eef2f7;
}

.privacy-section h2 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 1rem;
}

.home-shell {
    width: min(1120px, calc(100vw - 32px));
    margin: 48px auto;
}

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
    gap: 34px;
    align-items: center;
    min-height: calc(100vh - 220px);
}

.home-hero-copy {
    display: grid;
    gap: 18px;
}

.home-hero h1 {
    margin: 0;
    color: var(--text-main);
    font-size: 3rem;
    line-height: 1.08;
    letter-spacing: 0;
}

.home-hero p {
    margin: 0;
    color: #475467;
    font-size: 1.04rem;
    line-height: 1.7;
}

.home-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.home-preview {
    display: grid;
    grid-template-rows: 210px auto 104px;
    overflow: hidden;
    border: 1px solid #cfd8e6;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 20px 55px rgba(16, 24, 40, 0.14);
}

.preview-player {
    display: grid;
    grid-template-rows: 1fr 42px;
    background: #111827;
}

.preview-frame {
    margin: 22px auto 0;
    width: 72%;
    height: 150px;
    border-radius: 2px;
    background:
        linear-gradient(90deg, transparent 0 48%, rgba(250, 204, 21, 0.9) 48% 51%, transparent 51%),
        repeating-linear-gradient(90deg, #d1d5db 0 2px, #9ca3af 2px 4px);
    opacity: 0.9;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
}

.preview-controls span {
    display: block;
    height: 8px;
    border-radius: 999px;
    background: #e5e7eb;
}

.preview-controls span:nth-child(1) {
    width: 12px;
}

.preview-controls span:nth-child(2) {
    width: 120px;
}

.preview-controls span:nth-child(3) {
    margin-left: auto;
    width: 52px;
}

.preview-editor {
    display: grid;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid #d8dee8;
}

.preview-row,
.preview-time-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #475467;
    font-size: 0.78rem;
}

.preview-row strong {
    color: var(--text-main);
}

.preview-text {
    min-height: 58px;
    padding: 12px;
    border: 1px solid #cfd8e6;
    border-radius: 7px;
    color: var(--text-main);
    line-height: 1.5;
}

.preview-time-grid span {
    flex: 1;
    min-width: 0;
    padding: 8px;
    border: 1px solid #d8dee8;
    border-radius: 7px;
    background: #f8fafc;
    color: #475467;
    font-weight: 700;
    text-align: center;
}

.preview-timeline {
    position: relative;
    overflow: hidden;
    background: #edf4ff;
    border-top: 1px solid #d8dee8;
}

.preview-wave {
    position: absolute;
    left: 0;
    right: 0;
    top: 24px;
    height: 34px;
    background:
        repeating-linear-gradient(90deg, rgba(37, 99, 235, 0.18) 0 1px, transparent 1px 10px),
        linear-gradient(180deg, transparent 0 48%, rgba(71, 84, 103, 0.22) 48% 52%, transparent 52%);
}

.preview-cursor {
    position: absolute;
    top: 10px;
    bottom: 8px;
    left: 14px;
    width: 2px;
    background: #ef4444;
    z-index: 3;
}

.preview-block {
    position: absolute;
    left: 18px;
    bottom: 18px;
    width: 210px;
    height: 34px;
    overflow: hidden;
    border: 1px solid #93c5fd;
    border-radius: 6px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 34px;
    padding: 0 8px;
    white-space: nowrap;
}

.preview-block.second {
    left: 238px;
    width: 176px;
    background: #dbeafe;
    color: #1e3a8a;
}

.home-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.home-feature-grid article {
    padding: 18px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}

.home-feature-grid h2 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 1rem;
}

.home-feature-grid p {
    margin: 0;
    color: #475467;
    font-size: 0.9rem;
    line-height: 1.55;
}

.home-section {
    margin-top: 42px;
    padding-top: 28px;
    border-top: 1px solid #d8dee8;
}

.home-section-head {
    max-width: 720px;
    margin-bottom: 16px;
}

.home-section-head h2,
.info-hero h1 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 1.45rem;
    letter-spacing: 0;
}

.home-section-head p,
.info-hero p,
.info-section p,
.faq-list p {
    color: #475467;
    line-height: 1.65;
}

.home-trust-grid,
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.home-trust-grid article,
.info-grid article {
    padding: 18px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}

.home-trust-grid strong,
.info-grid strong {
    color: var(--text-main);
}

.home-trust-grid p,
.info-grid p {
    margin: 8px 0 0;
    color: #475467;
    font-size: 0.9rem;
    line-height: 1.55;
}

.format-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.format-list span {
    border: 1px solid #cfd8e6;
    border-radius: 999px;
    background: #ffffff;
    color: #344054;
    padding: 8px 12px;
    font-size: 0.84rem;
    font-weight: 800;
}

.faq-list {
    display: grid;
    gap: 10px;
}

.faq-list details {
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #ffffff;
    padding: 14px 16px;
}

.faq-list summary {
    cursor: pointer;
    color: var(--text-main);
    font-weight: 800;
}

.faq-list p {
    margin: 10px 0 0;
}

.info-shell {
    max-width: 860px;
}

.info-hero {
    padding: 18px 0 16px;
    border-bottom: 1px solid #d8dee8;
}

.info-section {
    padding: 20px 0;
    border-bottom: 1px solid #eef2f7;
}

.info-section h2 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 1rem;
}

.info-list {
    margin: 10px 0 0;
    padding-left: 20px;
    color: #475467;
    line-height: 1.7;
}

body.aws-body .aws-panel,
body.aws-review-body .ws-sidebar,
body.aws-review-body .player-container,
body.aws-review-body .timeline-container {
    border-color: var(--bg-panel-border);
}

body.aws-body .aws-panel {
    background: #ffffff;
    border: 1px solid var(--bg-panel-border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

body.aws-body .aws-panel-head {
    margin-bottom: 18px;
}

body.aws-body .aws-panel-head h2 {
    font-size: 1.05rem;
    color: var(--text-main);
}

body.aws-body .aws-form {
    gap: 14px;
}

body.aws-body .aws-form label {
    gap: 7px;
    color: #344054;
    font-weight: 700;
}

body.aws-body .aws-form label .text-muted {
    font-weight: 500;
}

body.aws-body .upload-zone {
    background: #f8fafc;
    border: 1px dashed #9aa9bd;
    border-radius: 8px;
    padding: 34px 16px;
    color: var(--text-main);
    text-align: center;
}

body.aws-body .upload-zone:hover {
    background: #eff6ff;
    border-color: var(--primary);
}

body.aws-body .upload-zone.dragging,
body.aws-body .upload-zone.has-file {
    background: #eefcf5;
    border-color: var(--success);
}

.aws-file-name {
    margin-top: 10px;
    font-weight: 700;
}

body.aws-body .aws-progress,
body.aws-review-body .aws-progress {
    background: #e5eaf2;
}

body.aws-body .aws-progress div,
body.aws-review-body .aws-progress div {
    background: linear-gradient(90deg, #2563eb, #059669);
}

body.aws-body .aws-message,
body.aws-review-body .aws-message {
    color: var(--text-muted);
}

body.aws-body .aws-message.error,
body.aws-review-body .aws-message.error {
    color: var(--danger);
}

body.aws-body .aws-alert {
    background: #fffbeb;
    border-color: #f4c563;
    color: #92400e;
}

body.aws-body .aws-job-row {
    background: #ffffff;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    color: var(--text-main);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

body.aws-body .aws-job-row:hover,
body.aws-body .aws-job-row.active {
    background: #eff6ff;
    border-color: #7aa2f7;
}

body.aws-body .aws-job-state {
    color: #667085;
}

.aws-job-note,
.aws-instruction-preview,
.review-context {
    margin-top: 8px;
    border-left: 3px solid #7aa2f7;
    background: #f0f6ff;
    color: #1f2937;
    border-radius: 7px;
    font-size: 0.82rem;
    line-height: 1.45;
}

.aws-job-note {
    padding: 7px 9px;
}

.aws-instruction-preview,
.review-context {
    padding: 10px 12px;
    white-space: pre-wrap;
}

body.aws-body .aws-selected-job {
    min-height: 0;
    color: var(--text-main);
}

body.aws-review-body .workspace {
    background: #eef2f7;
}

.ad-layout-review {
    grid-template-columns: 128px minmax(0, 1fr) 128px;
    width: min(1520px, calc(100vw - 24px));
    height: calc(100vh - 64px);
    margin: 0 auto;
    align-items: stretch;
}

.ad-layout-review .ad-rail {
    position: static;
    display: flex;
}

.ad-layout-review .ad-slot-rail {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
}

.ad-layout-review .workspace {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

body.aws-review-body .ws-main {
    background: #111827;
}

body.aws-review-body .player-container {
    background: #111827;
}

body.aws-review-body .timeline-container {
    height: 136px;
    background: #f8fafc;
    border-top: 1px solid #d8dee8;
}

body.aws-review-body .time-ruler {
    color: #475467;
    font-weight: 700;
}

body.aws-review-body .timeline-track {
    background: #e5eaf2;
    border-radius: 8px;
    margin-left: 8px;
    margin-right: 8px;
}

body.aws-review-body .timeline-block {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e3a8a;
    font-family: inherit;
}

body.aws-review-body .timeline-block:hover,
body.aws-review-body .timeline-block.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.26);
}

body.aws-review-body .ws-sidebar {
    background: #ffffff;
    color: var(--text-main);
    border-left: 1px solid var(--bg-panel-border);
    box-shadow: -1px 0 3px rgba(16, 24, 40, 0.06);
}

body.aws-review-body .current-subtitle-editor {
    background: #ffffff;
    color: var(--text-main);
    box-shadow: 0 -1px 2px rgba(16, 24, 40, 0.04);
}

body.aws-review-body .current-original-text {
    background: #f8fafc;
    color: var(--text-main);
}

body.aws-review-body #draftState.error {
    color: var(--danger);
}

body.aws-review-body .sub-table-container::-webkit-scrollbar-thumb,
body.aws-review-body .timeline-container::-webkit-scrollbar-thumb {
    background: #b8c3d4;
}

body.aws-review-body .sub-row {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    background: #ffffff;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    color: var(--text-main);
}

body.aws-review-body .sub-row:hover,
body.aws-review-body .sub-row.active,
body.aws-review-body .sub-row:focus-visible {
    background: #f0f6ff;
    border-color: #7aa2f7;
}

body.aws-review-body .sub-row-meta {
    color: #667085;
}

body.aws-review-body .sub-textarea {
    color: var(--text-main);
    background: #ffffff;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 8px;
}

body.aws-review-body .sub-textarea:focus {
    background: #ffffff;
    border-color: var(--primary);
}

body.aws-review-body .bg-glass {
    background: #f8fafc;
    backdrop-filter: none;
}

body.aws-review-body .border-bg-panel-border {
    border-color: #d8dee8;
}

@media (max-width: 900px) {
    body.aws-body .app-header,
    body.aws-review-body .app-header {
        height: auto;
        min-height: 64px;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    body.aws-body .tagline,
    body.aws-review-body .tagline {
        order: 3;
        width: 100%;
        margin-left: 0;
    }

    .site-nav {
        order: 3;
        width: 100%;
        margin-left: 0;
        gap: 12px;
        overflow-x: auto;
    }

    body.aws-body .aws-shell {
        width: calc(100vw - 20px);
        margin-top: 16px;
    }

    .ad-layout {
        grid-template-columns: minmax(0, 1fr);
        width: calc(100vw - 20px);
        margin: 16px auto 32px;
    }

    .ad-layout .aws-shell {
        width: 100%;
        margin: 0;
    }

    .ad-rail {
        display: none;
    }

    body.aws-body .aws-grid {
        grid-template-columns: 1fr;
    }

    .aws-market-row {
        grid-template-columns: 1fr;
    }

    body.aws-review-body {
        height: auto;
        overflow-y: auto;
    }

    body.aws-review-body .workspace {
        display: grid;
        height: auto;
        min-height: calc(100vh - 64px);
    }

    body.aws-review-body .ad-layout-review {
        width: 100%;
        height: auto;
        margin: 0;
    }

    body.aws-review-body .ad-layout-review .workspace {
        border-radius: 0;
    }

    body.aws-review-body .ws-sidebar {
        width: auto;
        border-left: 0;
        border-top: 1px solid var(--bg-panel-border);
    }

    .current-editor-grid {
        grid-template-columns: 1fr;
    }

    .subtitle-time-grid {
        grid-template-columns: 1fr;
    }

    .download-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .download-menu-panel {
        left: 0;
        right: auto;
    }

    .home-shell {
        width: calc(100vw - 20px);
        margin: 28px auto;
    }

    .home-hero {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .home-hero h1 {
        font-size: 2.25rem;
    }

    .home-preview {
        grid-template-rows: 190px auto 104px;
    }

    .home-feature-grid {
        grid-template-columns: 1fr;
    }

    .home-trust-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .subtitle-list-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
