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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
    color: #334e68;
    min-height: 100vh;
    padding: 30px 15px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.container {
    background: #ffffff;
    max-width: 860px;
    width: 100%;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    padding: 35px 30px;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Warning Banner for file:/// mode */
.file-warning-banner {
    background: #fffaf0;
    color: #7b341e;
    border: 2px solid #dd6b20;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.btn-switch-server {
    background: #dd6b20;
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-switch-server:hover {
    background: #c05621;
}

header {
    text-align: center;
    margin-bottom: 25px;
}

header h1 {
    font-size: 28px;
    color: #102a43;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

header p {
    color: #627d98;
    font-size: 15px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
    flex-wrap: wrap;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    color: #627d98;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    color: #243b53;
    background-color: #f0f4f8;
}

.tab-btn.active {
    color: #2b6cb0;
    background-color: #ebf8ff;
    border-bottom: 3px solid #3182ce;
    border-radius: 8px 8px 0 0;
}

.tab-btn#tab-cutter.active {
    color: #c53030;
    background-color: #fff5f5;
    border-bottom: 3px solid #e53e3e;
}

.badge-new {
    background: #e53e3e;
    color: white;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* YouTube Box */
.youtube-box {
    background: #fffaf0;
    border: 2px dashed #dd6b20;
    border-radius: 12px;
    padding: 25px 20px;
    margin-bottom: 20px;
}

.youtube-box label {
    display: block;
    color: #7b341e;
    margin-bottom: 10px;
    font-size: 15px;
}

.yt-input-row {
    display: flex;
    gap: 10px;
}

.yt-input-row input {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.yt-input-row input:focus {
    border-color: #dd6b20;
}

.btn-yt-fetch {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-yt-fetch:hover {
    background: #c53030;
}

.btn-yt-fetch:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.yt-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #9c4221;
}

/* Dropzone */
.dropzone {
    border: 2px dashed #627d98;
    border-radius: 12px;
    padding: 35px 20px;
    text-align: center;
    background-color: #f8fafc;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 20px;
}

.dropzone.dragover {
    border-color: #2b6cb0;
    background-color: #ebf8ff;
    transform: scale(1.01);
}

.dropzone-cutter {
    border-color: #e53e3e;
    background-color: #fff5f5;
}

.dropzone-cutter.dragover {
    border-color: #c53030;
    background-color: #fed7d7;
}

.dropzone-icon {
    font-size: 46px;
    margin-bottom: 10px;
}

.dropzone h3 {
    font-size: 18px;
    color: #243b53;
    margin-bottom: 6px;
}

.dropzone p {
    font-size: 14px;
    color: #829ab1;
}

#file-input, #file-input-cutter {
    display: none;
}

/* File Info Box */
.file-info-card {
    background: #f0f4f8;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 25px;
    display: none;
    border-left: 4px solid #3182ce;
}

.file-info-card h4 {
    color: #102a43;
    margin-bottom: 6px;
    font-size: 16px;
    word-break: break-all;
}

.file-meta {
    font-size: 14px;
    color: #486581;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.file-meta span strong {
    color: #243b53;
}

/* Mode Selection (Split vs Cut) */
.mode-selection {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 25px;
    background: #edf2f7;
    padding: 6px;
    border-radius: 12px;
}

.mode-btn {
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #486581;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.mode-btn:hover {
    color: #102a43;
}

.mode-btn.active {
    background: #ffffff;
    color: #2b6cb0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.mode-btn#btn-mode-cut.active {
    color: #c53030;
}

/* Tool Sections */
.tool-section {
    display: none;
}

.tool-section.active {
    display: block;
}

/* Split Controls */
#split-controls label {
    display: block;
    font-weight: 600;
    color: #243b53;
    margin-bottom: 10px;
    font-size: 15px;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.preset-btn {
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #334e68;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #e2e8f0;
}

.preset-btn.active {
    background: #3182ce;
    color: white;
    border-color: #3182ce;
}

.custom-parts-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-parts-input input {
    width: 100px;
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
}

.custom-parts-input input:focus {
    border-color: #3182ce;
}

/* Button Primary */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #3182ce 0%, #2b6cb0 100%);
    color: white;
    border: none;
    padding: 14px;
    font-size: 17px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
    margin-top: 15px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2b6cb0 0%, #2c5282 100%);
    box-shadow: 0 6px 15px rgba(49, 130, 206, 0.4);
}

.btn-primary:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    box-shadow: none;
}

/* ================== Cutter Card & Controls ================== */
.cutter-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px 20px;
    margin-bottom: 25px;
}

.cutter-player-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn-circle-play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #3182ce;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.btn-circle-play:hover {
    background: #2b6cb0;
    transform: scale(1.05);
}

.cutter-time-info {
    font-size: 16px;
    font-weight: 600;
    color: #102a43;
    font-variant-numeric: tabular-nums;
}

.cutter-selection-badge {
    margin-left: auto;
    background: #feebc8;
    color: #7b341e;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid #fbd38d;
}

/* Waveform Canvas & Track with Draggable Handles */
.waveform-container {
    position: relative;
    width: 100%;
    height: 80px;
    background: #111827;
    border-radius: 10px;
    overflow: visible;
    margin-top: 15px;
    margin-bottom: 30px;
    user-select: none;
    touch-action: none;
    cursor: pointer;
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 10px;
}

.waveform-highlight {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    background: rgba(229, 62, 62, 0.35);
    border-top: 2px solid #e53e3e;
    border-bottom: 2px solid #e53e3e;
    pointer-events: all;
    transition: none;
}

.selection-body {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 9px;
    right: 9px;
    cursor: grab;
}

.selection-body:active {
    cursor: grabbing;
}

.handle {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 18px;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    touch-action: none;
    user-select: none;
}

.handle-start {
    left: -9px;
    background: #e53e3e;
    border-radius: 6px 0 0 6px;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.4);
}

.handle-end {
    right: -9px;
    background: #e53e3e;
    border-radius: 0 6px 6px 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.4);
}

.handle-grip {
    width: 3px;
    height: 28px;
    background: white;
    border-radius: 2px;
    opacity: 0.95;
}

.handle-tag {
    position: absolute;
    bottom: -25px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    background: #1f2937;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.waveform-playhead {
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: 0;
    width: 2px;
    background: #fbbf24;
    pointer-events: none;
    z-index: 15;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.9);
}

.playhead-cap {
    position: absolute;
    top: 0;
    left: -5px;
    width: 12px;
    height: 12px;
    background: #fbbf24;
    border-radius: 50%;
    border: 2px solid #111827;
}

.track-hint {
    font-size: 12px;
    color: #718096;
    margin-bottom: 20px;
    text-align: center;
}

/* Time Inputs Container */
.time-inputs-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.time-box {
    background: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 14px;
}

.time-box label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #243b53;
    margin-bottom: 8px;
}

.time-digit-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.time-digit-inputs input {
    width: 65px;
    padding: 8px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #102a43;
    outline: none;
}

.time-digit-inputs input:focus {
    border-color: #3182ce;
}

/* Nudge Buttons */
.nudge-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.btn-nudge {
    flex: 1;
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    color: #4a5568;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-nudge:hover {
    background: #e2e8f0;
    color: #2b6cb0;
    border-color: #3182ce;
}

.btn-nudge:active {
    transform: scale(0.95);
}

.btn-set-time {
    width: 100%;
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    color: #2b6cb0;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-set-time:hover {
    background: #e2e8f0;
}

/* Cut Action Options (Radio Cards) */
.cut-action-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-card input {
    margin-top: 4px;
    cursor: pointer;
}

.radio-card.active {
    border-color: #e53e3e;
    background: #fff5f5;
}

.radio-card#label-action-keep.active {
    border-color: #38a169;
    background: #f0fff4;
}

.radio-card strong {
    font-size: 14px;
    color: #102a43;
    display: block;
    margin-bottom: 2px;
}

.radio-card p {
    font-size: 12px;
    color: #627d98;
    line-height: 1.4;
}

/* Preview Buttons */
.preview-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-secondary {
    flex: 1;
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    color: #2d3748;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: #1a202c;
}

.btn-cut-action {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.btn-cut-action:hover {
    background: linear-gradient(135deg, #c53030 0%, #9b2c2c 100%);
    box-shadow: 0 6px 15px rgba(229, 62, 62, 0.4);
}

/* Cut Results Card */
.cut-results-card {
    background: #f0fff4;
    border: 2px solid #9ae6b4;
    border-radius: 12px;
    padding: 22px;
    margin-top: 25px;
    display: none;
}

.cut-summary-badge {
    background: #c6f6d5;
    color: #22543d;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 15px;
    display: inline-block;
}

.cut-result-audio {
    margin-bottom: 18px;
}

.cut-result-audio audio {
    width: 100%;
    height: 42px;
}

.cut-result-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cut-result-buttons a,
.cut-result-buttons button {
    flex: 1;
    text-align: center;
    justify-content: center;
}

/* Status / Progress */
#status-area {
    margin-top: 20px;
    display: none;
    text-align: center;
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(49, 130, 206, 0.2);
    border-radius: 50%;
    border-top-color: #3182ce;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

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

.progress-bar-container {
    width: 100%;
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #3182ce;
    transition: width 0.3s;
}

#status-text {
    font-size: 15px;
    color: #486581;
    font-weight: 500;
}

/* Results Section (Split) */
#results-section {
    margin-top: 30px;
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.results-header h3 {
    color: #102a43;
    font-size: 20px;
}

.btn-download-all {
    background: #38a169;
    color: white;
    border: none;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-download-all:hover {
    background: #2f855a;
}

/* Parts Grid */
.parts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.part-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    transition: border-color 0.2s;
}

.part-card:hover {
    border-color: #cbd5e0;
}

.part-details {
    flex: 1;
}

.part-title {
    font-weight: 600;
    color: #102a43;
    font-size: 15px;
    margin-bottom: 4px;
}

.part-time {
    font-size: 13px;
    color: #627d98;
}

.part-audio {
    flex: 1.5;
    max-width: 280px;
}

.part-audio audio {
    width: 100%;
    height: 36px;
}

.btn-download-part {
    background: #3182ce;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    display: inline-block;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-download-part:hover {
    background: #2b6cb0;
}

@media (max-width: 650px) {
    .tabs {
        flex-direction: column;
    }
    .file-warning-banner {
        flex-direction: column;
        text-align: center;
    }
    .mode-selection {
        grid-template-columns: 1fr;
    }
    .time-inputs-container {
        grid-template-columns: 1fr;
    }
    .preview-buttons {
        flex-direction: column;
    }
    .cut-result-buttons {
        flex-direction: column;
    }
    .part-card {
        flex-direction: column;
        align-items: stretch;
    }
    .part-audio {
        max-width: 100%;
    }
    .results-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    .yt-input-row {
        flex-direction: column;
    }
}
