/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4338ca;
    --primary-hover: #3730a3;
    --primary-light: rgba(67, 56, 202, 0.08);
    --primary-glow: rgba(67, 56, 202, 0.25);
    --success: #059669;
    --success-hover: #047857;
    --error: #dc2626;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(67, 56, 202, 0.12);
    --shadow-btn-hover: 0 4px 12px rgba(67, 56, 202, 0.25), 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-btn-active: 0 1px 2px rgba(67, 56, 202, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Main */
main {
    flex: 1;
}

/* Input Section */
.input-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.input-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group input:disabled {
    background: var(--bg);
    cursor: not-allowed;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Buttons */
button, .primary-btn, .secondary-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    letter-spacing: 0.01em;
    position: relative;
}

button[type="submit"], .primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #5b4fd4 100%);
    color: white;
    box-shadow: var(--shadow-btn);
}

button[type="submit"]:hover, .primary-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #4338ca 100%);
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-1px);
}

button[type="submit"]:active, .primary-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-btn-active);
    background: linear-gradient(135deg, #312e81 0%, var(--primary-hover) 100%);
}

button[type="submit"]:focus-visible, .primary-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.secondary-btn {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.secondary-btn:hover {
    background: var(--bg);
    border-color: #cbd5e1;
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.secondary-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow);
}

.secondary-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.icon-btn {
    padding: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(67, 56, 202, 0.2);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Status Section */
.status-section {
    margin-bottom: 1.5rem;
}

.status-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-text {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

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

/* Error Section */
.error-section {
    margin-bottom: 1.5rem;
}

.error-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
}

.error-card h3 {
    color: var(--error);
    margin-bottom: 0.5rem;
}

.error-card p {
    color: #991b1b;
    margin-bottom: 1rem;
}

/* Result Section */
.result-section {
    margin-bottom: 1.5rem;
}

.result-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.result-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--success);
}

.result-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Transcript Block */
.transcript-block {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.transcript-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.transcript-text {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    min-height: 200px;
    max-height: 80vh;
    height: 400px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.7;
    resize: vertical;
}

/* Transcript paragraphs with timecodes */
.transcript-paragraph {
    margin-bottom: 0.75rem;
    position: relative;
    padding-left: 5.5rem;
}

.paragraph-timecode {
    position: absolute;
    left: 0;
    top: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    user-select: none;
    min-width: 5rem;
}

.transcript-word {
    cursor: text;
}

.transcript-word::selection {
    background: rgba(67, 56, 202, 0.2);
}

.word-highlighted {
    background: #fef08a;
    border-radius: 2px;
}

.transcript-duration {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Timecode selection bar */
.timecode-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    box-shadow: 0 1px 2px rgba(67, 56, 202, 0.06);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.timecode-range {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    white-space: nowrap;
}

.timecode-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, #5b4fd4 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(67, 56, 202, 0.2);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.timecode-add-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #4338ca 100%);
    box-shadow: 0 3px 8px rgba(67, 56, 202, 0.3);
    transform: translateY(-1px);
}

.timecode-add-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(67, 56, 202, 0.2);
}

/* Collector bar */
.collector-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.collector-info {
    color: #854d0e;
}

.collector-actions {
    display: flex;
    gap: 0.5rem;
}

.collector-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: linear-gradient(135deg, #92400e 0%, #854d0e 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(133, 77, 14, 0.2);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.collector-copy-btn:hover {
    background: linear-gradient(135deg, #78350f 0%, #713f12 100%);
    box-shadow: 0 3px 8px rgba(133, 77, 14, 0.3);
    transform: translateY(-1px);
}

.collector-copy-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(133, 77, 14, 0.2);
}

.collector-undo-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--card-bg);
    color: #92400e;
    border: 1px solid #e5a84c;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.collector-undo-btn:hover {
    background: #fef9c3;
    border-color: #d97706;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.15);
    transform: translateY(-1px);
}

.collector-undo-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.collector-clear-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--card-bg);
    color: #92400e;
    border: 1px solid #e5a84c;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.collector-clear-btn:hover {
    background: #fef9c3;
    border-color: #d97706;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.15);
    transform: translateY(-1px);
}

.collector-clear-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Cut Video Button */
.collector-cut-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--success) 0%, #0d9488 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.2);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.collector-cut-btn:hover {
    background: linear-gradient(135deg, var(--success-hover) 0%, #0f766e 100%);
    box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
    transform: translateY(-1px);
}

.collector-cut-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.2);
}

.collector-cut-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Cut Status */
.cut-status {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
}

.cut-status-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--success);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.cut-status-text {
    font-size: 0.85rem;
    color: var(--text);
}

.cut-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.cut-progress-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.3s ease;
}

/* Cut Results */
.cut-results {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
}

.cut-results-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #166534;
    margin-bottom: 0.4rem;
}

.cut-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.cut-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    background: white;
    border-radius: 4px;
    font-size: 0.85rem;
}

.cut-result-info {
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.cut-download-btn {
    padding: 0.25rem 0.6rem;
    background: linear-gradient(135deg, var(--success) 0%, #0d9488 100%);
    color: white;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.2);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: inline-block;
}

.cut-download-btn:hover {
    background: linear-gradient(135deg, var(--success-hover) 0%, #0f766e 100%);
    box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
    transform: translateY(-1px);
}

.cut-result-combined {
    margin-top: 0.3rem;
    padding-top: 0.5rem;
    border-top: 1px solid #bbf7d0;
}

.cut-result-combined-label {
    font-weight: 600;
    color: #166534;
}

.cut-download-combined {
    background: linear-gradient(135deg, var(--primary) 0%, #5b4fd4 100%);
    padding: 0.3rem 0.7rem;
    box-shadow: 0 1px 3px rgba(67, 56, 202, 0.2);
}

.cut-download-combined:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #4338ca 100%);
    box-shadow: 0 3px 8px rgba(67, 56, 202, 0.3);
}

/* Podvodki Block */
.podvodki-block {
    margin-bottom: 1.5rem;
}

.podvodki-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.podvodka-item {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    position: relative;
}

.podvodka-item::before {
    content: attr(data-variant);
    position: absolute;
    top: -0.5rem;
    left: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, #5b4fd4 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 3px rgba(67, 56, 202, 0.2);
    letter-spacing: 0.02em;
}

.podvodka-text {
    font-size: 0.95rem;
    line-height: 1.7;
}

.podvodka-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
}

/* New Job Button */
#newJobBtn {
    display: block;
    width: 100%;
    margin-top: 1rem;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    padding-top: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group button {
        width: 100%;
    }
}

/* Copy feedback */
.copy-success {
    background: var(--success) !important;
    color: white !important;
}
