       

        html {
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: var(--font-family-base);
            margin: 0;
            height: 100%;
            height: 100dvh;
            max-height: 100dvh;
            padding: 0;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            background-color: var(--body-background-light);
            color: var(--body-text-light);
        }

        body.dark-mode {
            background-color: var(--body-background-dark);
            color: var(--body-text-dark);
        }

        .layout-scale-viewport {
            flex: 1;
            min-height: 0;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            overflow: hidden;
        }

        .container {
            margin: 0 auto;
            padding: 28px 44px 18px;
            flex: 1 1 auto;
            width: 100%;
            min-height: 0;
            height: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr);
            grid-template-rows: auto minmax(0, 1.3fr) minmax(0, 1fr) auto 5.75rem;
            grid-template-areas:
                "header"
                "waveform"
                "notes"
                "transport"
                "projects";
            box-sizing: border-box;
            transform-origin: top center;
        }

        .container.layout-scaled-transform {
            margin-left: auto;
            margin-right: auto;
        }

        /* --- Header: title on the left, actions on the right --- */
        .app-header {
            grid-area: header;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 0;
            min-height: 52px;
            transition: opacity 0.25s ease-in-out;
        }

        .app-titles {
            display: flex;
            flex-direction: column;
            gap: 3px;
            min-width: 0;
            transition: opacity 0.25s ease-in-out;
        }

        .app-eyebrow {
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--grey-100);
        }

        .dark-mode .app-eyebrow {
            color: var(--grey-300);
        }

        .app-filename {
            font-size: 19px;
            font-weight: 700;
            color: var(--heading-color-light);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 52vw;
        }

        .dark-mode .app-filename {
            color: var(--heading-color-dark);
        }

        .app-actions {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-shrink: 0;
        }

        .btn-ghost {
            display: flex;
            align-items: center;
            gap: 7px;
            font-weight: 600;
            font-size: 14px;
        }

        /* The focus-mode toggle is the one button that stays emphasized -
           it's the button the whole "distraction-free" idea hangs off. */
        .btn-focus {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 0 18px;
            background: var(--heading-color-light);
            border-color: var(--heading-color-light);
            color: var(--white-200);
            font-weight: 700;
            font-size: 14px;
        }
        .btn-focus:hover {
            background: var(--black-200);
            border-color: var(--black-200);
            color: var(--white-200);
        }
        .dark-mode .btn-focus {
            background: var(--white-200);
            border-color: var(--white-200);
            color: var(--black-100);
        }
        .dark-mode .btn-focus:hover {
            background: var(--white-100);
            border-color: var(--white-100);
            color: var(--black-100);
        }

        .btn-icon {
            width: 42px;
            height: 42px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--grey-350);
        }

        .material-icon {
            font-family: 'Material Icons';
            font-size: 18px;
            line-height: 1;
        }

        /* --- "More" overflow menu (Load / Save / Settings) --- */
        .more-menu-wrap {
            position: relative;
            transition: opacity 0.25s ease-in-out;
        }

        .more-menu {
            display: none;
            flex-direction: column;
            gap: 2px;
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            min-width: 200px;
            padding: 6px;
            background: var(--modal-background-light);
            border: 1px solid var(--grey-500);
            border-radius: var(--control-radius);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
            z-index: 50;
        }

        .more-menu-wrap.open .more-menu {
            display: flex;
        }

        .dark-mode .more-menu {
            background: var(--modal-background-dark);
            border-color: var(--grey-900);
        }

        .more-menu-item {
            display: block;
            width: 100%;
            text-align: left;
            padding: 9px 12px;
            border: none;
            border-radius: 6px;
            background: transparent;
            color: var(--button-color-light);
            font: inherit;
            font-size: 14px;
            cursor: pointer;
            transition: var(--ani-button);
        }

        .more-menu-item:hover {
            background: var(--grey-600);
            color: var(--button-hover-color-light);
        }

        .dark-mode .more-menu-item {
            color: var(--button-color-dark);
        }

        .dark-mode .more-menu-item:hover {
            background: var(--grey-950);
            color: var(--button-hover-color-dark);
        }

        .main-area {
            grid-area: waveform;
            position: relative;
            padding: 0;
            border-radius: 8px;
            min-height: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .waveform-stage {
            position: relative;
            flex: 1 1 auto;
            min-height: 220px;
            margin-top: 18px;
            overflow: hidden;
        }

        .dots-container {
            position: absolute;
            inset: 0;
            height: auto;
            margin: 0;
            pointer-events: none;
            z-index: 2;
            transition: opacity 0.25s ease-in-out;
        }

        .section-dot {
            position: absolute;
            width: 9px;
            height: 9px;
            border-radius: 50%;
            top: 6px;
            transform: translateX(-4.5px);
        }

        #waveform-container {
            width: 100%;
            position: absolute;
            left: 0;
            right: 0;
            top: 20px;
            bottom: 0;
            height: auto;
            min-height: 0;
            background: transparent;
            margin-bottom: 0;
            overflow: hidden;
        }

        #waveform-container > div:not(.section-overlay) {
            width: 100% !important;
            height: 100% !important;
            max-height: 100%;
            overflow: hidden;
            box-sizing: border-box;
        }

        #waveform-container wave,
        #waveform-container canvas {
            min-height: 0 !important;
            max-height: 100%;
        }

        .section-line {
            position: absolute;
            width: 1.5px;
            background: var(--section-line-color-general);
            top: 16px;
            height: 204px; /* updated from JS to match waveform height */
            z-index: 10;
        }

        .section-overlay {
            position: absolute;
            top: 0;
            height: 100%; /* Or the height of your waveform */
            opacity: 0.14;
            border-radius: var(--block-radius);
            pointer-events: none; /* Allows clicks to pass through to the waveform below */
            z-index: 5; /* Ensure it's above the waveform but below markers/cursor */
            transition: opacity 0.3s ease-in-out; /* Add transition for fade */
        }

        .timeline {
            display: flex;
            justify-content: space-between;
            flex-shrink: 0;
            margin-top: 8px;
            margin-bottom: 0;
            padding: 0 1px;
            font-size: 12px;
            font-weight: 500;
            color: var(--timeline-color-light);
            transition: opacity 0.25s ease-in-out;
        }

        .dark-mode .timeline {
            color: var(--timeline-color-dark);
        }

        #sections-bar {
            width: 100%;
            height: 44px;
            flex-shrink: 0;
            background: var(--sections-bar-background-light);
            position: relative;
            margin-top: 12px;
            margin-bottom: 0;
            border-radius: var(--block-radius);
        }

        .dark-mode #sections-bar {
            background: var(--sections-bar-background-dark);
        }

        /* Sections bar: block just carries its name now (no description
           clutter) - the waveform overlay is the source of truth for where
           a section actually sits on the audio. */
        .section-block {
            position: absolute;
            height: 44px;
            top: 0;
            border-radius: var(--block-radius);
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
            color: var(--white-200); /* Text inside section block is always white for contrast */
            font-size: 13px;
            font-weight: 700;
            cursor: grab;
            padding: 5px 20px 5px 5px; /* right padding clears the edit button */
            box-sizing: border-box;
            user-select: none;
            overflow: hidden;
            transition: opacity 0.2s ease-in-out;
        }

        body.is-section-dragging,
        body.is-section-dragging .section-block {
            cursor: grabbing;
            user-select: none;
        }

        .section-edit-btn {
            position: absolute;
            top: 2px;
            right: 6px;
            width: 18px;
            height: 18px;
            padding: 0;
            border: none;
            border-radius: 3px;
            background: rgba(0, 0, 0, 0.28);
            color: var(--white-200);
            font-family: 'Material Icons';
            font-size: 14px;
            line-height: 18px;
            cursor: pointer;
            z-index: 21;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: opacity 0.2s ease-in-out;
        }

        .section-edit-btn:hover {
            background: rgba(0, 0, 0, 0.45);
        }

        body.is-section-dragging .section-edit-btn {
            cursor: grabbing;
            pointer-events: none;
        }

        .section-title {
            font-weight: 700;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .handle {
            position: absolute;
            width: 12px;
            height: 12px;
            background: var(--handle-background-light);
            border: 2px solid var(--handle-border-light);
            border-radius: 50%;
            cursor: ew-resize;
            top: 50%;
            transform: translate(-50%, -50%);
            z-index: 20;
            transition: var(--ani-button);
        }

        .handle:hover {
            background: var(--handle-hover-background-light);
        }


        .notes-container {
            grid-area: notes;
            min-height: 0;
            overflow: hidden;
            margin-top: 16px;
            padding-top: 0;
            border-top: none;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .dark-mode .notes-container {
            border-top-color: transparent;
        }

     

        .notes-content {
            flex: 1;
            min-height: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .notes-header {
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding-bottom: 0;
            margin-bottom: 0;
            border-bottom: none;
        }


        .section-header {
            font-size: 15px;
            font-weight: 700;
            color: var(--heading-color-light);
            flex: 1;
        }

        .dark-mode .section-header {
            color: var(--sections-label-color-dark);
        }

        #section-content-notes {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
        }

        .play-controls {
            grid-area: transport;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 18px;
            margin-top: 0;
            padding: 12px 0 0;
            border-top: 1px solid var(--grey-75);
            transition: opacity 0.25s ease-in-out;
        }

        .play-time {
            width: 120px;
            text-align: right;
            font-size: 13px;
            font-weight: 600;
            color: var(--grey-100);
        }

        .play-time-spacer {
            width: 120px;
        }

        .play-btn {
            width: 46px;
            height: 46px;
            border: 1.5px solid var(--play-btn-border-light);
            border-radius: 50%;
            cursor: pointer;
            font-size: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--play-btn-color-light);
            font-family: 'Material Icons';
            background: var(--white-200);
            transition: var(--ani-button);
        }

        .play-btn.play-toggle {
            width: 58px;
            height: 58px;
            border-color: var(--black-100);
            background: var(--black-100);
            color: var(--white-200);
        }

        .play-btn:hover {
            border-color: var(--play-btn-hover-border-light);
            color: var(--play-btn-hover-color-light);
        }

        .play-btn.play-toggle:hover {
            border-color: var(--black-200);
            background: var(--black-200);
            color: var(--white-200);
        }

        .dark-mode .play-btn:hover {
            border-color: var(--play-btn-hover-border-dark);
            color: var(--play-btn-hover-color-dark);
        }

        .dark-mode .play-btn {
            border-color: var(--play-btn-border-dark);
            color: var(--play-btn-color-dark);
            background: transparent;
        }

        .dark-mode .play-btn.play-toggle {
            border-color: var(--white-200);
            background: var(--white-200);
            color: var(--black-100);
        }

        /* --- UNIFIED .btn STYLES --- */
        .btn {
            padding: 0 16px;
            background: var(--button-background-light);
            border: 1px solid var(--button-border-light);
            border-radius: var(--control-radius);
            color: var(--button-color-light);
            cursor: pointer;
            transition: var(--ani-button);
            height: 42px;
            font-family: inherit;
        }

        .btn:hover {
            border-color: var(--button-hover-border-light);
            color: var(--button-hover-color-light);
            background: var(--button-hover-background-light);
        }

        .dark-mode .btn {
            background: var(--button-background-dark);
            border-color: var(--button-border-dark);
            color: var(--button-color-dark);
        }
        .dark-mode .btn:hover {
            background: var(--button-hover-background-dark);
            border-color: var(--button-hover-border-dark);
            color: var(--button-hover-color-dark);
        }



        /* --- Recent projects (always reserved so the grid never shifts) --- */
        .file-history {
            grid-area: projects;
            min-height: 0;
            margin-top: 8px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            transition: opacity 0.25s ease-in-out;
        }

        .file-history h3 {
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--timeline-color-light);
            margin: 0 0 8px;
        }

        .dark-mode .file-history h3 {
            color: var(--body-text-dark);
        }

        .file-buttons {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
            gap: 10px;
            min-height: 42px;
            overflow-x: auto;
        }

        .file-buttons-empty {
            font-size: 13px;
            color: var(--grey-100);
            line-height: 42px;
        }

        .file-project {
            position: relative;
            display: inline-flex;
            align-items: stretch;
            max-width: 240px;
        }

        .file-btn {
            display: inline-flex;
            align-items: center;
            height: 42px;
            padding: 0 36px 0 16px;
            border-radius: var(--control-radius);
            font: inherit;
            font-size: 13px;
            font-weight: 600;
            max-width: 240px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: pointer;
            background: var(--button-background-light);
            border: 1px solid var(--button-border-light);
            color: var(--button-color-light);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
            transition: var(--ani-button);
        }

        .file-btn:hover {
            background: var(--button-hover-background-light);
            border-color: var(--button-hover-border-light);
            color: var(--button-hover-color-light);
        }

        .dark-mode .file-btn {
            background: var(--button-background-dark);
            border-color: var(--button-border-dark);
            color: var(--button-color-dark);
            box-shadow: none;
        }

        .dark-mode .file-btn:hover {
            background: var(--button-hover-background-dark);
            border-color: var(--button-hover-border-dark);
            color: var(--button-hover-color-dark);
        }


        .file-remove {
            position: absolute;
            right: 5px;
            top: 50%;
            transform: translateY(-50%);
            background: var(--accent-red); /* Retains red for the 'remove' icon */
            color: var(--white-200);
            border: none;
            border-radius: 50%;
            width: 16px;
            height: 16px;
            font-size: 10px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: var(--ani-button);
        }

        /* --- Modals --- */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
        }

        .modal-content {
            background: var(--modal-background-light);
            margin: 15% auto;
            padding: 20px;
            border-radius: 4px;
            width: 300px;
            max-width: 90%;
            color: var(--modal-text-light);
        }

        .dark-mode .modal-content {
            background: var(--modal-background-dark);
            color: var(--modal-text-dark);
        }

        .modal input {
            width: 100%;
            padding: 8px;
            margin: 5px 0;
            border: 1px solid var(--modal-input-border-light);
            border-radius: 4px;
            box-sizing: border-box;
            background: var(--modal-input-background-light);
            color: var(--modal-input-color-light);
        }

        .color-picker {
            width: 100%;
            height: 40px;
            padding: 0;
            border: 1px solid var(--modal-input-border-light);
            border-radius: 4px;
            cursor: pointer;
            margin: 5px 0;
        }

        .dark-mode .modal input {
            background: var(--modal-input-background-dark);
            border-color: var(--modal-input-border-dark);
            color: var(--modal-input-color-dark);
        }

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

        /* --- Footer --- */
        .footer {
            font-size: 10px;
            color: var(--footer-color-light);
            position: absolute;
            bottom: 10px;
            right: 60px;
            transition: opacity 0.3s ease-in-out; /* Add transition for fade */
        }

        .dark-mode .footer {
            color: var(--footer-color-dark);
        }

        /* Hidden/fixed extras must occupy an existing grid cell so they
           cannot insert a new row and shift the layout. */
        .container > #toast-container,
        .container > #zipFileInput {
            grid-area: 1 / 1;
            justify-self: start;
            align-self: start;
        }

        /* --- Toast Notifications --- */
        #toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1100;
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
        }

        .toast {
            pointer-events: auto;
            background-color: var(--toast-background-default);
            color: var(--toast-color-default);
            padding: 10px 20px;
            border-radius: 5px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            opacity: 0;
            transform: translateY(-20px);
            animation: slideIn 0.3s forwards, fadeOut 0.5s 4.5s forwards;
            min-width: 250px;
            max-width: 350px;
            word-wrap: break-word;
        }

        .toast.warning {
            background-color: var(--accent-warning);
            color: var(--toast-warning-color-light);
        }

        .toast.success {
            background-color: var(--accent-success);
            color: var(--toast-success-color-light);
        }

        .toast.info {
            background-color: var(--accent-info);
            color: var(--toast-info-color-light);
        }

        .dark-mode .toast.warning {
            background-color: var(--accent-warning-dark);
            color: var(--toast-warning-color-dark);
        }

        .dark-mode .toast.success {
            background-color: var(--accent-success-dark);
            color: var(--toast-success-color-dark);
        }

        .dark-mode .toast.info {
            background-color: var(--accent-info-dark);
            color: var(--toast-info-color-dark);
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes fadeOut {
            from {
                opacity: 1;
            }
            to {
                opacity: 0;
                transform: translateY(-20px);
            }
        }

        /* Class to hide elements with a fade effect */
        .hidden-element {
            opacity: 0 !important;
            pointer-events: none !important; /* Prevents interaction when hidden */
            transition: opacity 0.3s ease-in-out;
        }

    .help-text {
        position: absolute;
        top: 12px;
        left: 18px;
        z-index: 20;
        color: var(--grey-100);
        text-decoration: none !important;
        font-size: 12px;
        margin-left: 0;
        padding: 0;
        border: 0;
        background: none;
        font-family: inherit;
        cursor: pointer;
    }