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

html,
body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100% !important;
    position: relative;
}

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --secondary-color: #6c757d;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ===== Container ===== */
.container {
    max-width: 1400px;
    /* Increased to accommodate sidebar */
    margin: 0 auto;
    padding: 20px;
}

/* ===== Layout Wrapper (Sidebar + Content) ===== */
.main-wrapper {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.main-content {
    flex: 1;
    min-width: 0;
    /* Prevents overflow issues */
}

/* ===== Feature Blocks (SPA Model) ===== */
.feature-block {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.feature-block.active {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Sidebar Navigation ===== */
.side-nav {
    width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 15px;
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    background: none;
    text-align: left;
    font-size: 1rem;
    font-family: inherit;
}

.nav-item:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(118, 75, 162, 0.3);
}

/* Flagship Highlight */
.side-nav a[href="#splitter"].nav-item {
    border: 1px solid rgba(118, 75, 162, 0.2);
    position: relative;
    overflow: hidden;
}

.side-nav a[href="#splitter"].nav-item::after {
    content: "Flagship";
    position: absolute;
    top: 5px;
    right: -18px;
    background: #ff4757;
    color: white;
    font-size: 0.6rem;
    padding: 2px 20px;
    transform: rotate(45deg);
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.side-nav a[href="#splitter"].nav-item.active::after {
    background: #ffffff;
    color: #764ba2;
}

.feature-title.flagship-title {
    border-left: 5px solid #ff4757;
    padding-left: 15px;
    position: relative;
}

.flagship-badge {
    display: inline-block;
    background: #ff4757;
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-icon {
    font-size: 1.2rem;
}

.nav-text {
    font-weight: 500;
}

.nav-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 5px 0;
}

.help-item {
    color: var(--primary-color);
    margin-top: auto;
    /* Push to bottom if fixed height */
}

.help-item:hover {
    background-color: #eef2ff;
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 30px 20px;
    /* Slimmed down a bit */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    position: relative;
    /* For lang switcher absolute positioning */
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.version {
    opacity: 0.8;
    font-size: 0.9rem;
}

.section-lang-switcher {
    position: absolute;
    right: 20px;
    bottom: 15px;
    margin-top: 0;
}

.lang-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.4);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-weight: 500;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
}

.lang-btn.active {
    background: white;
    color: #764ba2;
    border-color: white;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    opacity: 1;
}

.main-tools-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    margin-top: 5px;
}

.main-tools-buttons .btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    /* Distribute space evenly */
}

/* Fix for marking buttons text overflow */
#btnMarkSegment,
#btnMarkContinue,
#btnMarkFinish {
    font-size: 0.9rem;
    padding: 6px 4px;
    min-width: 0;
}

/* Remove spinner from step size input */
#stepSize::-webkit-inner-spin-button,
#stepSize::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

#stepSize {
    -moz-appearance: textfield;
    appearance: textfield;
}

.seek-marker {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 18px;
    width: 3px;
    background-color: #ff4757;
    z-index: 5;
    pointer-events: none;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
    border-radius: 1px;
}

/* ===== Sections ===== */
.section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    /* Box shadow removed here to avoid nested card look issues, controlled by feature-block now or kept minimal */
    border: 1px solid var(--border-color);
}

.section h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-color);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ===== Feature Blocks (New Top Level layout) ===== */
.feature-block {
    background: white;
    border-radius: 12px;
    margin-bottom: 40px;
    /* More space between main features */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Conspicuous shadow */
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.feature-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    font-size: 1.4rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Add padding to the content area of feature block */
.feature-block .section {
    margin: 20px;
    box-shadow: none;
    /* Flat inside */
    background: var(--bg-color);
    /* Slight contrast inside white feature block */
}

/* ===== File Upload ===== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    /* Ensure upload area is white */
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.05);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.1);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.upload-prompt p {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.file-info {
    text-align: left;
}

.file-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.file-details {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ===== Audio Player ===== */
.audio-player {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#audioPlayer {
    width: 100%;
    height: 40px;
}

.waveform-container {
    width: 100%;
    height: 120px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

#waveformCanvas {
    width: 100%;
    height: 100%;
}

/* ===== Player Controls ===== */
.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    flex-wrap: wrap;
}

.btn-player {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: white;
    color: #667eea;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-player:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-player.active {
    background: #667eea;
    color: white;
}

.seek-bar-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    color: white;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
}

.seek-bar {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

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

.seek-bar::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.speed-select {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: white;
    color: #667eea;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
}

.speed-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

/* ===== Settings ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.setting-item input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 10px;
}

/* Video Converter Controls */
.video-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Audio Converter Controls */
.audio-convert-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

@media (min-width: 769px) {

    .video-controls,
    .audio-convert-controls {
        flex-direction: row;
        align-items: flex-end;
        flex-wrap: wrap;
    }

    .video-controls .btn,
    .audio-convert-controls .btn {
        margin-left: auto;
    }
}

.preset-buttons,
.auto-split-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-preset,
.btn-split {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-preset:hover,
.btn-split:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== Segments ===== */
.segments-header {
    display: grid;
    grid-template-columns: 80px 1fr 150px 150px 200px;
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 4px;
    font-weight: bold;
    margin-bottom: 10px;
}

.segments-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.segment-row {
    display: grid;
    grid-template-columns: 80px 1fr 150px 150px 200px;
    gap: 10px;
    padding: 12px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 8px;
    align-items: center;
    transition: all 0.2s;
    background: white;
    /* Ensure card background */
}

@media (max-width: 768px) {
    .segments-header {
        display: none;
        /* Hide header on mobile */
    }

    .segment-row {
        grid-template-columns: 80px 1fr;
        /* ID | Name */
        grid-template-areas:
            "id name"
            "start end"
            "actions actions";
        gap: 8px;
        padding: 15px;
        height: auto;
    }

    /* Assign grid areas */
    .segment-row> :nth-child(1) {
        grid-area: id;
        width: 100%;
    }

    .segment-row> :nth-child(2) {
        grid-area: name;
        width: 100%;
    }

    .segment-row> :nth-child(3) {
        grid-area: start;
        justify-self: center;
    }

    .segment-row> :nth-child(4) {
        grid-area: end;
        justify-self: center;
    }

    .segment-row> :nth-child(5) {
        grid-area: actions;
        justify-self: center;
        width: 100%;
        justify-content: center;
        margin-top: 5px;
        border-top: 1px solid #eee;
        padding-top: 10px;
    }

    /* Adjust inputs for mobile */
    .segment-id-input {
        width: 100% !important;
        text-align: center;
    }

    .time-input-group {
        width: 100%;
        justify-content: center;
    }

    .time-input {
        width: 90px;
        padding: 6px;
        font-size: 0.9rem;
    }

    /* Indentation for sub-segments */
    .segment-row.sub-segment {
        margin-left: 10px;
        border-left-width: 4px;
    }

    .segment-row.level-3 {
        margin-left: 20px;
        border-left-width: 4px;
    }
}

.segment-row:hover {
    background: var(--bg-color);
    box-shadow: var(--shadow);
}

.segment-row.sub-segment {
    margin-left: 20px;
    border-left: 3px solid var(--primary-color);
}

.segment-row.level-3 {
    margin-left: 40px;
    border-left: 3px solid var(--success-color);
}

.segment-row input {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
}

.time-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-input {
    width: 110px;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 1rem;
    text-align: center;
}

.time-adjust-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-adjust-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.segment-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

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

.btn-icon.add-sub {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-icon.delete {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* ===== Sub-segment Menu ===== */
.sub-segment-menu {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    min-width: 220px;
    overflow: hidden;
    animation: menuFadeIn 0.15s ease;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-title {
    padding: 12px 15px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.9rem;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 12px 15px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s;
}

.menu-item:hover {
    background: #f0f4ff;
}

.menu-item.menu-cancel {
    color: var(--danger-color);
    border-top: 1px solid var(--border-color);
}

.segments-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

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

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

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

.btn-secondary:hover {
    background: #5a6268;
}

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

.btn-success:hover {
    background: #218838;
    box-shadow: var(--shadow-hover);
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.2rem;
    width: 100%;
}

/* ===== Export ===== */
.export-options {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 1rem;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.export-controls {
    margin-bottom: 20px;
}

/* ===== Progress ===== */
.progress-container {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--bg-color);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.progress-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
        /* Smaller on mobile */
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .container {
        padding: 5px;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .header {
        padding: 15px 10px;
        border-radius: 8px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .feature-title {
        word-break: break-word;
        /* Ensure clear break on long titles */
        padding-right: 5px;
    }

    .main-wrapper {
        flex-direction: column;
        gap: 12px;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
        box-sizing: border-box;
        padding: 0 2px;
    }

    .side-nav {
        width: 100%;
        position: static;
        /* No longer sticky on mobile */
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
        justify-content: center;
    }

    .nav-item {
        flex: 1 1 calc(50% - 10px);
        min-width: 0;
        max-width: calc(50% - 10px);
        justify-content: center;
        padding: 8px 5px;
        font-size: 0.85rem;
    }

    .nav-text {
        font-size: 0.9rem;
    }

    /* Hide divider on mobile row layout */
    .nav-divider {
        display: none;
    }

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

    /* Hide desktop header */
    .segments-header {
        display: none;
    }

    /* Mobile segment row - 4 rows layout */
    .segment-row {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 12px;
    }

    .segment-row.sub-segment {
        margin-left: 15px;
        border-left: 4px solid var(--primary-color);
    }

    /* Row 1: ID + Name */
    .segment-row .segment-id-input {
        width: 60px;
        font-size: 1rem;
        padding: 8px;
    }

    .segment-row>input:nth-child(2) {
        flex: 1;
        font-size: 1rem;
        padding: 10px;
    }

    /* Time input groups - full width */
    .segment-row .time-input-group {
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 8px;
    }

    /* Time inputs larger on mobile */
    .segment-row .time-input {
        flex: 1;
        max-width: 140px;
        font-size: 1.1rem;
        padding: 12px 8px;
        text-align: center;
    }

    /* +/- buttons - DO NOT shrink, keep large */
    .segment-row .time-adjust-btn {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px;
        min-height: 48px;
        font-size: 1.4rem;
        flex-shrink: 0;
    }

    /* Actions row - full width, centered */
    .segment-row .segment-actions {
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 12px;
        padding-top: 5px;
        border-top: 1px solid var(--border-color);
    }

    /* Action buttons - DO NOT shrink, keep large */
    .segment-row .btn-icon {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px;
        min-height: 48px;
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    /* Segment controls buttons */
    .segments-controls {
        flex-direction: column;
        gap: 8px;
    }

    .segments-controls .btn {
        width: 100%;
    }
}

/* ===== Floating Player Bar ===== */
.floating-player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    /* v1.5.8 Style Spacing */
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* Desktop horizontal wrapper */
/* Removed .floating-player-contents as per instruction */

.floating-player-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.floating-player-controls .btn-player {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-player-controls .btn-player:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.floating-player-controls .btn-player.active {
    background: #667eea;
    border-color: #667eea;
}

.floating-player-seekbar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.floating-player-seekbar .seek-bar {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
}

.floating-player-seekbar .seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

.floating-player-time {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
    min-width: 85px;
}

.floating-settings-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.floating-player-speed {
    display: flex;
    gap: 10px;
}

.floating-player-speed .speed-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.floating-player-speed .speed-select option {
    background: #1a1a2e;
    color: white;
}

.floating-player-info {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

body.player-active {
    padding-bottom: 80px;
}

.btn-play-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .floating-player-bar {
        flex-direction: row !important;
        flex-wrap: wrap;
        padding: 5px 10px 10px;
        gap: 5px;
        justify-content: space-between;
    }

    /* Seekbar Row 1 */
    .floating-player-seekbar {
        order: 1;
        width: 100% !important;
        flex: none;
        flex-direction: row !important;
        align-items: center;
        gap: 10px;
        margin-bottom: 5px;
    }

    .floating-player-seekbar .seek-bar {
        height: 6px;
    }

    .floating-player-time {
        min-width: 65px;
        font-size: 0.75rem;
    }

    /* Controls and Settings Row 2 */
    .floating-player-controls {
        order: 2;
        flex: 0 1 auto;
        gap: 4px;
    }

    .floating-settings-row {
        order: 3;
        flex: 0 1 auto;
        gap: 5px;
        justify-content: flex-end;
    }

    /* Adjust sizing for Row 2 side-by-side compact fit */
    .floating-player-controls .btn-player {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }

    .speed-select {
        height: 30px;
        font-size: 0.75rem !important;
        padding: 0 4px !important;
        max-width: 48px;
    }

    .floating-player-mode .floating-checkbox-label {
        font-size: 0.75rem;
        gap: 3px;
    }

    .floating-player-info {
        display: none !important;
    }

    body.player-active {
        padding-bottom: 100px;
    }
}

/* ===== File Info Row ===== */
.file-info-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
}

.file-info-row .file-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.file-info-row .btn-play-main {
    padding: 6px 15px;
    font-size: 0.9rem;
}

/* ===== Drag and Drop Styles ===== */
.segment-row {
    cursor: grab;
}

.segment-row.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.segment-row.drag-over {
    border-top: 3px solid #667eea;
    padding-top: 7px;
}

.segment-id-input {
    width: 80px;
    text-align: center;
    font-weight: bold;
}

/* ===== Export Options ===== */
.export-option-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.export-option-group label {
    min-width: 80px;
}

.export-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    font-size: 0.95rem;
    cursor: pointer;
}

/* ===== Playback Mode Selector ===== */
.floating-player-mode .mode-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
}

.floating-player-mode .mode-select option {
    background: #1a1a2e;
    color: white;
}

/* ===== Section Header Row ===== */
.section-header-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.section-header-row h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* Secondary switcher - removed as redundant to header switcher */

/* ===== Floating Checkbox ===== */
.floating-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
}

.floating-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

/* ===== Settings Drag & Drop ===== */
.segments-list.drag-active {
    position: relative;
    border: 3px dashed var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
    min-height: 200px;
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 4px;
    pointer-events: none;
}

.drop-message {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 20px;
    border: 2px dashed white;
    border-radius: 8px;
}

/* ===== Help Button ===== */
.help-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 10px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.help-btn:hover {
    opacity: 1;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    color: var(--text-color);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 10px;
}

.close-modal:hover,
.close-modal:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.manual-body {
    line-height: 1.6;
}

.manual-body h3 {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
    margin-top: 20px;
    color: var(--primary-color);
}

.manual-body ul {
    padding-left: 20px;
}

.manual-body li {
    margin-bottom: 8px;
}

/* ===== Merge Section ===== */
.merge-upload-area {
    border: 2px dashed var(--border-color);
    padding: 25px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 15px;
}

.merge-upload-area:hover,
.merge-upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.merge-list {
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.merge-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: grab;
    transition: transform 0.2s, background 0.2s;
}

.merge-item.dragging {
    opacity: 0.5;
    background: rgba(102, 126, 234, 0.3);
}

.merge-item-info {
    font-size: 0.9em;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-merge-item-play {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-merge-item-play:hover {
    background: var(--primary-color);
    color: white;
}

.merge-item-time {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: #eee;
}

.merge-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.merge-filename-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 4px;
    margin-right: 15px;
    flex-grow: 1;
    min-width: 150px;
}

.merge-filename-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.merge-item.drag-over-item {
    border-bottom: 2px solid var(--primary-color);
}

.merge-item-name {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.merge-item-info {
    font-size: 0.85rem;
    color: #aaa;
    margin-right: 15px;
}

.btn-remove-merge {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
}

.merge-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}