* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --error: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #ffffff;
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid var(--gray-200);
}

.dot-gray {
    background: var(--gray-300);
}

.dot-green {
    background: var(--success);
}

/* Add file bar */
.add-file-bar {
    margin-bottom: 16px;
    text-align: left;
}

.add-file-bar.hidden {
    display: none;
}

.add-file-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.record-row {
    margin-bottom: 12px;
    display: flex;
    justify-content: flex-start;
}

/* Card */
.card {
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-100);
    padding: 24px;
}

.upload-card.hidden {
    display: none;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 48px 24px;
    text-align: center;
    transition: all 0.2s ease;
    background: var(--gray-50);
}

.dropzone.collapsed {
    padding: 0;
    border: none;
    background: transparent;
}

.dropzone-content.hidden {
    display: none;
}

.dropzone:hover:not(.collapsed),
.dropzone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    color: var(--gray-400);
    margin-bottom: 16px;
}

.dropzone.dragover .dropzone-icon {
    color: var(--primary);
}

.dropzone-text {
    font-size: 16px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.dropzone-hint {
    font-size: 13px;
    color: var(--gray-400);
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn-success:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-large {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    margin-top: 20px;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.btn-icon-small {
    width: 14px;
    height: 14px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* Upload status */
.upload-status {
    margin-top: 14px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
}

.upload-status.hidden {
    display: none;
}

.upload-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.upload-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
}

#uploadBarFill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.2s ease;
}

/* File List */
.file-list {
    margin-top: 20px;
}

.file-list:empty {
    display: none;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.file-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon.audio {
    background: #dbeafe;
    color: var(--primary);
}

.file-icon.video {
    background: #fce7f3;
    color: #db2777;
}

.file-icon svg {
    width: 20px;
    height: 20px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--gray-500);
}

.file-remove {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.file-remove:hover {
    background: var(--gray-200);
    color: var(--error);
}

.file-remove svg {
    width: 16px;
    height: 16px;
}

/* Sections */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 16px;
}

.drag-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--gray-400);
}

.jobs-section,
.results-section {
    margin-top: 32px;
    display: none;
}

.jobs-section.visible,
.results-section.visible {
    display: block;
}

/* Jobs - Transcript Cards with drag support */
.jobs-list {
    min-height: 20px;
}

.job-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    padding-right: 44px; /* Space for delete button */
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    user-select: none;
}

.job-item:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.job-item.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

/* Drag and drop styles */
.job-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.job-item.drag-over {
    border-color: var(--primary);
    border-style: dashed;
    background: #eff6ff;
}

.job-item .drag-handle {
    cursor: grab;
    color: var(--gray-300);
    padding: 4px;
    margin-left: -8px;
    display: flex;
    align-items: center;
}

.job-item .drag-handle:active {
    cursor: grabbing;
}

.job-item .drag-handle svg {
    width: 16px;
    height: 16px;
}

.job-status-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.job-status-icon svg {
    width: 16px;
    height: 16px;
}

.job-status-icon.queued {
    background: var(--gray-100);
    color: var(--gray-500);
}

.job-status-icon.processing {
    background: #dbeafe;
    color: var(--primary);
}

.job-status-icon.done {
    background: #d1fae5;
    color: var(--success);
}

.job-status-icon.failed {
    background: #fee2e2;
    color: var(--error);
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-meta {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 2px;
}

.job-status-text {
    font-size: 12px;
    color: var(--gray-500);
}

/* Job delete button - FIX 1: always visible on mobile */
.job-delete {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    background: white;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    /* Always visible, not opacity: 0 */
}

.job-delete:hover {
    background: #fee2e2;
    color: var(--error);
    border-color: #fecaca;
}

.job-delete svg {
    width: 14px;
    height: 14px;
}

/* Job progress bar */
.job-progress-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

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

/* Spinner - FIX 4: constrained size */
svg.spinner {
    animation: spin 1s linear infinite;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
}

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

/* Results */
.result-item {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    display: none;
    position: relative;
}

.result-item.visible {
    display: block;
}

/* Result close button */
.result-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    background: white;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    z-index: 10;
}

.result-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.result-close svg {
    width: 16px;
    height: 16px;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-right: 40px;
}

.result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

/* Transcript actions */
.transcript-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.transcript-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
    position: relative;
}

.transcript-actions .btn-copy {
    padding-left: 9px;
    padding-right: 9px;
}

.transcript-actions .btn-translate {
    padding-left: 11px;
    padding-right: 11px;
}

.transcript-actions .btn svg {
    width: 14px;
    height: 14px;
}

/* Download menu */
.download-menu-wrapper {
    position: relative;
    display: inline-block;
}

.download-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 140px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
}

.download-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.download-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--gray-700);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}

.download-menu-item:hover {
    background: var(--gray-50);
}

.download-menu-item:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.download-menu-item:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.transcript-box {
    position: relative;
}

.transcript-text {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--gray-700);
    max-height: 700px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.transcript-text.editing {
    outline: 2px solid var(--primary);
    background: #ffffff;
}

/* Custom Audio Player */
.audio-player {
    margin-top: 16px;
}

.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--gray-50) 0%, #f0f4f8 100%);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

/* Big play button */
.play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.play-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.play-btn:active {
    transform: scale(0.98);
}

.play-btn svg {
    width: 24px;
    height: 24px;
}

.play-btn .play-icon {
    margin-left: 3px;
}

.play-btn .pause-icon {
    display: none;
}

.play-btn.playing .play-icon {
    display: none;
}

.play-btn.playing .pause-icon {
    display: block;
}

/* Audio controls */
.audio-controls {
    flex: 1;
    min-width: 0;
}

.audio-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.audio-time {
    font-size: 12px;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
}

.audio-time.current {
    text-align: right;
}

.audio-time.duration {
    text-align: left;
}

.audio-progress-wrapper {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.audio-progress {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.audio-progress-wrapper:hover .audio-progress {
    background: var(--primary-hover);
}

/* Bottom audio controls */
.audio-bottom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px; /* move controls 10px right (requested) */
}

/* Speed selector */
.speed-select {
    height: 32px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: white;
    color: var(--gray-700);
    padding: 0 8px;
    cursor: pointer;
}

.volume-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.volume-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.volume-btn svg {
    width: 18px;
    height: 18px;
}

.volume-popover {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.volume-popover-panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 10px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
}

.volume-popover-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* slider size inside popover */
.volume-popover-panel .volume-slider {
    width: 140px;
}

.volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-200);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.1s;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

/* Audio download button */
.audio-download-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    background: white;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626; /* slightly darker red */
}

.audio-download-btn:hover {
    background: var(--gray-50);
    color: var(--primary);
    border-color: var(--primary);
}

.audio-download-btn svg {
    width: 18px;
    height: 18px;
}

/* Audio loading - FIX 4: small spinner, not huge */
.audio-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--gray-500);
}

.audio-loading svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Error */
.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 16px;
}

.error-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--error);
    margin-bottom: 4px;
}

.error-detail {
    font-size: 13px;
    color: #991b1b;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 400px;
    padding: 20px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    font-size: 20px;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body label {
    display: block;
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.lang-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--gray-800);
}

.modal-note {
    margin-top: 16px;
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
}

#micPermissionModal .modal-note {
    font-size: 13px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}

/* Footer */
.footer {
    margin-top: 48px;
    text-align: center;
}

.privacy-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-500);
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.privacy-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 16px 12px;
    }

    .logo {
        font-size: 24px;
    }

    .card {
        padding: 16px;
    }

    .dropzone {
        padding: 32px 16px;
    }

    .dropzone-icon {
        width: 40px;
        height: 40px;
    }

    .dropzone-text {
        font-size: 14px;
    }

    .file-item {
        padding: 10px;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .transcript-actions {
        width: 100%;
    }

    .transcript-actions .btn {
        flex: 1;
        min-width: 0;
    }

    .custom-audio-player {
        flex-wrap: wrap;
        gap: 12px;
    }

    .audio-controls {
        width: 100%;
        order: 2;
    }

    .play-btn {
        width: 48px;
        height: 48px;
    }

    .play-btn svg {
        width: 20px;
        height: 20px;
    }

    .audio-bottom-row {
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
        margin-left: 0; /* mobile: no extra indentation */
    }

    .audio-bottom-row .speed-select {
        order: 1;
    }

    .audio-bottom-row .volume-btn {
        order: 2;
    }

    .audio-bottom-row .audio-download-btn {
        order: 3;
        margin-left: auto;
    }

    .audio-bottom-row .volume-slider {
        order: 10;
        width: 100%;
        max-width: none;
        margin-top: 10px;
    }

    .volume-popover-panel .volume-slider {
        width: 180px;
    }

    /* Drag hint hidden on mobile - touch drag works differently */
    .drag-hint {
        display: none;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.toast.error {
    background: var(--error);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
