    * { box-sizing: border-box; }
    html, body { height:100%; margin:0; background:#0a0a0a; font-family: system-ui, -apple-system, sans-serif; }

    .app { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100vh; overflow: hidden; }

    /* Sidebar */
    .sidebar {
      background: #111;
      border-right: 1px solid #222;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      overflow-x: hidden;
      min-width: 320px;
      flex-shrink: 0;
      scrollbar-width: thin;
      scrollbar-color: #444 transparent;
    }
    .sidebar::-webkit-scrollbar { width: 5px; }
    .sidebar::-webkit-scrollbar-track { background: transparent; }
    .sidebar::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
    .sidebar::-webkit-scrollbar-thumb:hover { background: #555; }
    .sidebar-header {
      padding: 16px;
      border-bottom: 1px solid #222;
      background: #0d0d0d;
    }
    .sidebar-header h1 {
      margin: 0;
      font-size: 20px;
      color: #fff;
      font-weight: 700;
    }
    .sidebar-header span {
      font-size: 11px;
      color: #999;
    }

    .sidebar-section {
      padding: 12px 16px;
      border-bottom: 1px solid #1a1a1a;
    }
    .sidebar-section h3 {
      margin: 0 0 10px 0;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: #999;
    }
    #visualizerSection,
    #miniBarsSection,
    #crossPulseSection {
      margin-left: 4px;
      border-left: 2px solid transparent;
      transition: border-left-color 0.15s;
    }
    #visualizerSection.active,
    #miniBarsSection.active,
    #crossPulseSection.active {
      border-left-color: #ff9500;
    }
    #crossPulseSection {
      display: none;
    }
    .text-group {
      border-left: 2px solid transparent;
    }
    .text-group:has(.text-accordion-header.open) {
      border-left-color: #ff9500;
    }
    .text-accordion-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 0;
      cursor: pointer;
      user-select: none;
    }
    .text-accordion-header .accordion-arrow {
      font-size: 8px;
      color: #666;
      transition: transform 0.15s;
      width: 10px;
    }
    .text-accordion-header.open .accordion-arrow {
      transform: rotate(90deg);
    }
    .text-accordion-body {
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.2s ease-out;
    }
    .text-accordion-body.open {
      max-height: 500px;
      transition: max-height 0.25s ease-in;
    }

    /* Controls */
    .control-row {
      display: flex;
      gap: 8px;
      margin-bottom: 8px;
    }
    .control-row.full { flex-direction: column; }

    label.control {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      color: #aaa;
    }
    label.control input[type="range"] {
      flex: 1;
      min-width: 80px;
    }
    label.control input[type="checkbox"] {
      width: 16px;
      height: 16px;
    }
    label.control select {
      flex: 1;
      padding: 6px 8px;
      background: #1a1a1a;
      border: 1px solid #333;
      border-radius: 6px;
      color: #ccc;
      font-size: 12px;
    }

    .btn {
      padding: 10px 14px;
      border: 0;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.15s;
    }
    .btn-primary { background: #f90; color: #000; }
    .btn-primary:hover { background: #fa0; }
    .btn-secondary { background: #222; color: #ccc; }
    .btn-secondary:hover { background: #333; }
    .btn-danger { background: #600; color: #faa; }
    .btn-danger:hover { background: #800; }
    .btn-success { background: #060; color: #afa; }
    .btn-success:hover { background: #080; }
    .btn-full { width: 100%; }

    /* Toggle Switch */
    .toggle-switch input:checked + .toggle-slider { background-color: #4a9eff; }
    .toggle-slider:before {
      position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px;
      background-color: white; transition: .2s; border-radius: 50%;
    }
    .toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }

    .file-input-wrap {
      position: relative;
      display: block;
    }
    .file-input-wrap input[type="file"] {
      position: absolute;
      top: 0;
      left: 0;
      opacity: 0;
      width: 100%;
      height: 100%;
      cursor: pointer;
      z-index: 10;
    }

    /* Main Area */
    .main {
      display: flex;
      flex-direction: column;
      background: #000;
      overflow-y: auto;
      overflow-x: hidden;
      scrollbar-width: thin;
      scrollbar-color: #444 transparent;
    }
    .main::-webkit-scrollbar { width: 5px; }
    .main::-webkit-scrollbar-track { background: transparent; }
    .main::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
    .main::-webkit-scrollbar-thumb:hover { background: #555; }

    .canvas-wrap {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px 20px 10px 20px;
    }
    canvas {
      max-width: 100%;
      max-height: calc(100vh - 200px);
      border-radius: 12px;
      background: #111;
      /* GPU acceleration */
      transform: translateZ(0);
      will-change: contents;
      image-rendering: auto;
    }

    /* Timeline */
    .timeline {
      height: 80px;
      background: #111;
      border-top: 1px solid #222;
      padding: 10px 16px;
    }
    /* Playlist timeline (all tracks) */
    .playlist-timeline {
      height: 24px;
      background: #1a1a1a;
      border-radius: 4px;
      position: relative;
      overflow: hidden;
      cursor: pointer;
      margin-bottom: 6px;
    }
    .playlist-timeline .timeline-tracks {
      display: flex;
      height: 100%;
    }
    .playlist-timeline .timeline-track {
      height: 100%;
      border-right: 1px solid #333;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 9px;
      color: #999;
      min-width: 2px;
      transition: background 0.2s;
    }
    .playlist-timeline .timeline-track:hover {
      background: #333;
    }
    .playlist-timeline .timeline-track.active {
      background: rgba(255, 153, 0, 0.3);
      color: #f90;
    }
    /* Track timeline (current track) */
    .track-timeline {
      height: 20px;
      background: #1a1a1a;
      border-radius: 4px;
      position: relative;
      overflow: hidden;
      cursor: pointer;
    }
    .track-timeline .track-progress {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: rgba(255, 153, 0, 0.35);
      border-right: 2px solid #fa0;
      pointer-events: none;
      z-index: 2;
      transform-origin: left;
      transform: scaleX(0);
    }
    .track-timeline .track-time-label {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      font-size: 10px;
      color: #fff;
      pointer-events: none;
    }
    .track-timeline .track-time-label.current { left: 8px; }
    .track-timeline .track-time-label.total { right: 8px; color: #aaa; }
    /* DAW-Quality Waveform Canvas */
    .track-waveform-canvas {
      position: absolute;
      left: 0; top: 0;
      width: 100%; height: 100%;
      pointer-events: none;
      z-index: 1;
    }
    /* Trim handles */
    .track-timeline .trim-handle {
      position: absolute;
      width: 6px;
      height: 100%;
      background: #ff4444;
      cursor: ew-resize;
      z-index: 10;
      opacity: 0.8;
      border-radius: 2px;
    }
    .track-timeline .trim-handle:hover {
      opacity: 1;
      background: #ff6666;
    }
    .track-timeline .trim-handle.start { left: 0; border-radius: 2px 0 0 2px; }
    .track-timeline .trim-handle.end { right: 0; border-radius: 0 2px 2px 0; }
    /* Trim region overlay */
    .track-timeline .trim-region {
      position: absolute;
      top: 0; height: 100%;
      background: rgba(255,0,0,0.15);
      pointer-events: none;
      z-index: 2;
    }
    .track-timeline .trim-region.start { left: 0; }
    .track-timeline .trim-region.end { right: 0; }
    .timeline-info {
      display: flex;
      justify-content: space-between;
      margin-top: 4px;
      font-size: 10px;
      color: #999;
    }

    /* Playback Controls */
    .playback-controls {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 16px;
      background: #0d0d0d;
      border-top: 1px solid #222;
    }
    .control-buttons {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .control-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: #333;
      border: 0;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.2s;
      position: relative;
    }
    .control-btn:hover { background: #444; }
    .control-btn.play { background: #f90; }
    .control-btn.play:hover { background: #fa0; }
    .control-btn.stop { background: #c33; }
    .control-btn.stop:hover { background: #e44; }
    /* CSS Icon: Play (triangle) */
    .icon-play {
      width: 0; height: 0;
      border-top: 6px solid transparent;
      border-bottom: 6px solid transparent;
      border-left: 10px solid #fff;
      margin-left: 2px;
    }
    /* CSS Icon: Pause (two bars) */
    .icon-pause {
      display: flex; gap: 3px;
    }
    .icon-pause::before, .icon-pause::after {
      content: '';
      width: 4px; height: 12px;
      background: #fff;
    }
    /* CSS Icon: Stop (square) */
    .icon-stop {
      width: 10px; height: 10px;
      background: #fff;
    }
    /* CSS Icon: Prev (two triangles left) */
    .icon-prev {
      display: flex; align-items: center;
    }
    .icon-prev::before, .icon-prev::after {
      content: '';
      width: 0; height: 0;
      border-top: 5px solid transparent;
      border-bottom: 5px solid transparent;
      border-right: 7px solid #fff;
    }
    /* CSS Icon: Next (two triangles right) */
    .icon-next {
      display: flex; align-items: center;
    }
    .icon-next::before, .icon-next::after {
      content: '';
      width: 0; height: 0;
      border-top: 5px solid transparent;
      border-bottom: 5px solid transparent;
      border-left: 7px solid #fff;
    }
    .playback-controls .track-info {
      flex: 1;
    }
    .playback-controls .track-title {
      font-size: 14px;
      color: #fff;
      margin-bottom: 2px;
    }
    .playback-controls .track-artist {
      font-size: 11px;
      color: #999;
    }
    .playback-controls .time-info {
      font-size: 12px;
      color: #aaa;
      font-variant-numeric: tabular-nums;
    }
    .volume-control {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-left: 12px;
    }
    .volume-icon {
      font-size: 16px;
      cursor: pointer;
    }
    .volume-control input[type="range"] {
      width: 80px;
      height: 4px;
      cursor: pointer;
    }

    /* Bottom Playlist Panel */
    .bottom-playlist-panel {
      background: #0d0d0d;
      border-top: 1px solid #222;
      display: flex;
      flex-direction: column;
    }
    .bottom-playlist-header {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 16px;
      background: #111;
      border-bottom: 1px solid #1a1a1a;
    }
    .bottom-playlist-header .file-input-wrap {
      position: relative;
    }
    .bottom-playlist-header .file-input-wrap input[type="file"] {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
    }
    .bottom-playlist-header .btn-add {
      padding: 6px 12px;
      background: #f90;
      color: #000;
      border: none;
      border-radius: 4px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
    }
    .bottom-playlist-header .btn-add:hover { background: #ffaa33; }
    .bottom-playlist-header .btn-clear {
      padding: 6px 12px;
      background: #333;
      color: #aaa;
      border: none;
      border-radius: 4px;
      font-size: 12px;
      cursor: pointer;
    }
    .bottom-playlist-header .btn-clear:hover { background: #444; color: #fff; }
    .transition-controls {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 0 8px;
      border-left: 1px solid #333;
    }
    .transition-controls select {
      padding: 4px 6px;
      background: #222;
      border: 1px solid #333;
      border-radius: 4px;
      color: #aaa;
      font-size: 11px;
      cursor: pointer;
    }
    .transition-setting {
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .transition-setting input[type="range"] {
      width: 70px;
      height: 4px;
      cursor: pointer;
    }
    .transition-setting span {
      font-size: 10px;
      color: #999;
      min-width: 32px;
    }
    .transition-controls .btn-apply {
      padding: 4px 8px;
      background: #f90;
      color: #000;
      border: none;
      border-radius: 4px;
      font-size: 10px;
      font-weight: 600;
      cursor: pointer;
      margin-left: 4px;
    }
    .transition-controls .btn-apply:hover { background: #ffaa33; }
    .bottom-playlist-header .playlist-info {
      flex: 1;
      text-align: right;
      font-size: 11px;
      color: #999;
    }
    .select-all-wrap {
      display: flex;
      align-items: center;
      gap: 4px;
      font-size: 11px;
      color: #aaa;
      cursor: pointer;
      margin-left: 10px;
    }
    .select-all-wrap:hover { color: #f90; }
    .select-all-wrap input[type="checkbox"] {
      accent-color: #f90;
      cursor: pointer;
    }
    .track-checkbox {
      accent-color: #f90;
      cursor: pointer;
      width: 16px;
      height: 16px;
    }
    .playlist-scroll-container {
    }
    .bottom-playlist-list {
      padding: 8px;
    }

    /* Repeat Preview Styles */
    #repeatPreview {
      margin-top: 4px;
      padding: 0 8px 16px 8px;
    }
    .repeat-preview-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      background: #252525;
      border-radius: 6px;
      margin-bottom: 4px;
      pointer-events: none;
      border-left: 3px solid #f90;
    }
    .repeat-preview-item .num {
      width: 28px;
      height: 28px;
      font-size: 12px;
      color: #f90;
      text-align: center;
      line-height: 28px;
      background: #1a1a1a;
      border-radius: 4px;
      font-weight: 600;
    }
    .repeat-preview-item .info {
      flex: 1;
      min-width: 0;
    }
    .repeat-preview-item .name {
      font-size: 13px;
      color: #ddd;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-bottom: 2px;
    }
    .repeat-preview-item .duration {
      font-size: 11px;
      color: #999;
      margin-right: 8px;
    }
    .repeat-cycle-label {
      text-align: center;
      color: #f90;
      font-size: 12px;
      font-weight: 600;
      padding: 12px 0 8px 0;
      border-top: 1px dashed #555;
      margin-top: 12px;
      letter-spacing: 1px;
    }

    .bottom-playlist-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 12px;
      background: #1a1a1a;
      border-radius: 6px;
      margin-bottom: 4px;
      cursor: pointer;
      transition: background 0.15s;
      border-left: 3px solid transparent;
    }
    .bottom-playlist-item:hover { background: #222; }
    .bottom-playlist-item.selected { background: #252525; border-left-color: #666; }
    .bottom-playlist-item.playing { background: #2a2a2a; border-left-color: #f90; }
    .bottom-playlist-item.paused { background: #252520; border-left-color: #aa6600; }
    .bottom-playlist-item .num {
      width: 24px;
      font-size: 11px;
      color: #999;
      text-align: center;
    }
    .bottom-playlist-item .info {
      flex: 1;
      min-width: 0;
    }
    .bottom-playlist-item .title {
      font-size: 13px;
      color: #ddd;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .bottom-playlist-item .title input.title-edit {
      background: transparent;
      border: none;
      border-bottom: 1px solid #888;
      outline: none;
      font-size: 13px;
      color: #ddd;
      width: 100%;
      padding: 0;
      font-family: inherit;
    }
    .bottom-playlist-item .artist {
      font-size: 11px;
      color: #999;
    }
    .bottom-playlist-item .duration {
      font-size: 11px;
      color: #999;
      margin-right: 8px;
    }
    .bottom-playlist-item .controls {
      display: flex;
      gap: 4px;
    }
    .bottom-playlist-item .controls button {
      width: 24px;
      height: 24px;
      border: none;
      background: #333;
      color: #aaa;
      border-radius: 4px;
      cursor: pointer;
      font-size: 10px;
    }
    .bottom-playlist-item .controls button:hover { background: #444; color: #fff; }
    .bottom-playlist-item .controls button:disabled { opacity: 0.3; cursor: not-allowed; }
    /* Track timeline in playlist item */
    .bottom-playlist-item .track-timeline {
      flex-basis: 100%;
      height: 64px;
      margin-top: 8px;
      background: #0d0d0d;
      border: 1px solid #222;
      border-radius: 4px;
    }
    .bottom-playlist-item {
      flex-wrap: wrap;
    }
    /* Drag and drop */
    .bottom-playlist-item.dragging { opacity: 0.4; }
    .bottom-playlist-item.drag-over { border-top: 2px solid #f90; margin-top: -2px; }
    .bottom-playlist-item .drag-handle {
      cursor: grab;
      color: #444;
      font-size: 14px;
      padding: 0 4px;
      user-select: none;
    }
    .bottom-playlist-item .drag-handle:hover { color: #aaa; }
    .bottom-playlist-item .drag-handle:active { cursor: grabbing; }
    /* Track play/stop button */
    .bottom-playlist-item .track-play-btn {
      width: 28px;
      height: 28px;
      border: 1px solid #444;
      background: #2a2a2a;
      color: #888;
      border-radius: 50%;
      cursor: pointer;
      font-size: 11px;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      transition: all 0.15s;
    }
    .bottom-playlist-item .track-play-btn:hover {
      background: #333;
      border-color: #666;
      color: #fff;
    }
    .bottom-playlist-item.playing .track-play-btn {
      color: #f90;
      border-color: #f90;
    }
    /* Cover art thumbnail */
    .bottom-playlist-item .cover-art {
      width: 36px;
      height: 36px;
      border-radius: 4px;
      background: #222;
      object-fit: cover;
      flex-shrink: 0;
    }
    .bottom-playlist-item .cover-placeholder {
      width: 36px;
      height: 36px;
      border-radius: 4px;
      background: linear-gradient(135deg, #333 0%, #222 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      color: #444;
      flex-shrink: 0;
    }
    /* Per-track transition controls */
    .bottom-playlist-item .track-transition {
      display: flex;
      align-items: center;
      gap: 4px;
      margin-left: 8px;
      padding-left: 8px;
      border-left: 1px solid #333;
    }
    .bottom-playlist-item .track-transition select {
      padding: 2px 4px;
      background: #222;
      border: 1px solid #333;
      border-radius: 3px;
      color: #aaa;
      font-size: 10px;
      cursor: pointer;
    }
    .bottom-playlist-item .track-transition input[type="range"] {
      width: 50px;
      height: 3px;
      cursor: pointer;
    }
    .bottom-playlist-item .track-transition span {
      font-size: 9px;
      color: #999;
      min-width: 24px;
    }
    .bottom-playlist-item .track-transition .gap-ctrl,
    .bottom-playlist-item .track-transition .fade-ctrl {
      display: flex;
      align-items: center;
      gap: 2px;
    }
    /* Track control column headers */
    .track-col-header {
      font-size: 8px;
      color: #999;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 2px;
      text-align: center;
      font-weight: 500;
    }
    .track-col {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-left: 8px;
    }
    /* Per-track visualizer selector */
    .bottom-playlist-item .track-visual {
      margin-left: 8px;
    }
    .bottom-playlist-item .track-visual select {
      padding: 3px 6px;
      background: #2a2a2a;
      border: 1px solid #444;
      border-radius: 4px;
      color: #f90;
      font-size: 10px;
      cursor: pointer;
      font-weight: 500;
    }
    .bottom-playlist-item .track-visual select:hover {
      background: #333;
      border-color: #555;
    }
    /* Per-track Audio Enhancement */
    .bottom-playlist-item .track-enhancement {
      margin-left: 4px;
      position: relative;
    }
    .bottom-playlist-item .track-enhancement-btn {
      padding: 3px 6px;
      background: #2a2a2a;
      border: 1px solid #444;
      border-radius: 4px;
      color: #888;
      font-size: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 3px;
      min-width: 50px;
    }
    .bottom-playlist-item .track-enhancement-btn:hover {
      background: #333;
      border-color: #555;
      color: #aaa;
    }
    .bottom-playlist-item .track-enhancement-btn.has-preset {
      color: #9cf;
      border-color: #456;
    }
    .bottom-playlist-item .track-enhancement-btn.is-bypass {
      color: #f96;
      border-color: #654;
    }
    .track-enhancement-popover {
      position: fixed;
      background: #1a1a1a;
      border: 1px solid #444;
      border-radius: 6px;
      padding: 10px;
      min-width: 200px;
      z-index: 10000;
      box-shadow: 0 4px 12px rgba(0,0,0,0.5);
      display: none;
    }
    .track-enhancement-popover.show { display: block; }
    .track-enhancement-popover h4 {
      margin: 0 0 8px 0;
      font-size: 11px;
      color: #9cf;
      font-weight: 600;
    }
    .track-enhancement-popover label {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 4px 0;
      font-size: 11px;
      color: #aaa;
      cursor: pointer;
    }
    .track-enhancement-popover label:hover { color: #fff; }
    .track-enhancement-popover select {
      width: 100%;
      padding: 4px 6px;
      margin-top: 4px;
      background: #222;
      border: 1px solid #444;
      border-radius: 4px;
      color: #fff;
      font-size: 10px;
    }
    .track-enhancement-popover .preset-select-wrapper {
      margin-left: 18px;
      margin-top: 4px;
    }
    .bottom-playlist-empty {
      padding: 30px;
      text-align: center;
      color: #444;
      font-size: 13px;
    }
    .bottom-playlist-loading {
      padding: 20px;
      text-align: center;
      color: #f90;
      font-size: 13px;
    }
    .bottom-playlist-loading .spinner {
      display: inline-block;
      width: 16px;
      height: 16px;
      border: 2px solid #333;
      border-top-color: #f90;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      margin-right: 8px;
      vertical-align: middle;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* Export Modal */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.8);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }
    .modal-overlay.active { display: flex; }
    .modal {
      background: #1a1a1a;
      border-radius: 16px;
      padding: 24px;
      width: 400px;
      max-width: 90vw;
      max-height: 90vh;
      overflow-y: auto;
    }
    .modal h2 {
      margin: 0 0 16px 0;
      font-size: 18px;
      color: #fff;
    }
    .modal-row {
      margin-bottom: 12px;
    }
    .modal-row label {
      display: block;
      font-size: 12px;
      color: #aaa;
      margin-bottom: 4px;
    }
    .modal-row select, .modal-row input {
      width: 100%;
      padding: 10px;
      background: #222;
      border: 1px solid #333;
      border-radius: 8px;
      color: #fff;
      font-size: 14px;
    }
    .modal-actions {
      display: flex;
      gap: 8px;
      margin-top: 20px;
      justify-content: center;
    }
    .export-progress {
      margin-top: 16px;
    }
    .export-progress-bar {
      height: 8px;
      background: #333;
      border-radius: 4px;
      overflow: hidden;
    }
    .export-progress-fill {
      height: 100%;
      background: #f90;
      width: 0%;
      transition: width 0.3s;
    }
    .export-progress-text {
      font-size: 11px;
      color: #aaa;
      margin-top: 6px;
      text-align: center;
    }

    /* Background Timeline Section */
    .bg-section {
      background: #0d0d0d;
      border-bottom: 1px solid #222;
      padding: 8px 12px;
    }
    .bg-section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 8px;
    }
    .bg-section-title {
      font-size: 12px;
      font-weight: 600;
      color: #888;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    .bg-actions {
      display: flex;
      gap: 6px;
    }
    .btn-sm {
      padding: 4px 10px;
      font-size: 11px;
    }
    /* Now Playing badge for Audio Enhancement */
    .now-playing-badge {
      font-size: 9px;
      padding: 2px 8px;
      border-radius: 10px;
      font-weight: bold;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    .now-playing-badge.global {
      background: #2a4a2a;
      color: #8f8;
      border: 1px solid #4a6a4a;
    }
    .now-playing-badge.preset {
      background: #4a3a2a;
      color: #fc8;
      border: 1px solid #6a5a4a;
    }
    .now-playing-badge.bypass {
      background: #4a2a2a;
      color: #f96;
      border: 1px solid #6a4a4a;
    }
    .bg-library {
      display: flex;
      gap: 8px;
      padding: 8px 0;
      overflow-x: auto;
      min-height: 55px;
      align-items: center;
    }
    .bg-library-empty, .bg-timeline-empty {
      color: #555;
      font-size: 11px;
      font-style: italic;
    }
    .bg-library-item {
      width: 80px;
      height: 45px;
      border-radius: 4px;
      overflow: hidden;
      cursor: grab;
      position: relative;
      flex-shrink: 0;
      border: 2px solid transparent;
      transition: border-color 0.2s;
    }
    .bg-library-item:hover {
      border-color: #f90;
    }
    .bg-library-item.dragging {
      opacity: 0.5;
    }
    .bg-library-item img,
    .bg-library-item video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      pointer-events: none;
    }
    .bg-library-item .type-badge {
      position: absolute;
      top: 2px;
      left: 2px;
      font-size: 9px;
      background: rgba(0,0,0,0.7);
      color: #fff;
      padding: 1px 4px;
      border-radius: 2px;
    }
    .bg-library-item .duration-badge {
      position: absolute;
      bottom: 2px;
      right: 2px;
      font-size: 9px;
      background: rgba(0,0,0,0.7);
      color: #fff;
      padding: 1px 4px;
      border-radius: 2px;
    }
    .bg-library-item .delete-btn {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 16px;
      height: 16px;
      background: rgba(255,0,0,0.8);
      color: #fff;
      border: none;
      border-radius: 50%;
      font-size: 10px;
      cursor: pointer;
      display: none;
      align-items: center;
      justify-content: center;
      line-height: 1;
    }
    .bg-library-item:hover .delete-btn {
      display: flex;
    }
    .bg-timeline-zoom {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 2px 4px;
    }
    .bg-timeline-zoom .zoom-label {
      font-size: 10px;
      color: #888;
      white-space: nowrap;
    }
    .bg-timeline-zoom input[type="range"] {
      width: 90px;
      height: 3px;
      accent-color: #ff9500;
      cursor: pointer;
    }
    .bg-timeline-container {
      background: #1a1a1a;
      border-radius: 4px;
      overflow-x: auto;
      overflow-y: hidden;
      margin-top: 4px;
      /* Modern thin scrollbar */
      scrollbar-width: thin;
      scrollbar-color: #444 #1a1a1a;
    }
    .bg-timeline-container::-webkit-scrollbar {
      height: 6px;
    }
    .bg-timeline-container::-webkit-scrollbar-track {
      background: #1a1a1a;
      border-radius: 3px;
    }
    .bg-timeline-container::-webkit-scrollbar-thumb {
      background: #444;
      border-radius: 3px;
    }
    .bg-timeline-container::-webkit-scrollbar-thumb:hover {
      background: #555;
    }
    .bg-timeline-ruler {
      height: 18px;
      background: #111;
      border-bottom: 1px solid #333;
      position: relative;
      font-size: 9px;
      color: #666;
      min-width: fit-content;
    }
    .bg-timeline-ruler .tick {
      position: absolute;
      top: 0;
      height: 100%;
      border-left: 1px solid #333;
      padding-left: 3px;
      display: flex;
      align-items: center;
    }
    .bg-timeline {
      height: 50px;
      position: relative;
      min-width: fit-content;
      background: #1a1a1a;
    }
    .bg-timeline.drag-over {
      background: #2a2a2a;
    }
    .bg-timeline-item {
      position: absolute;
      height: calc(100% - 4px);
      top: 2px;
      border-radius: 4px;
      cursor: move;
      display: flex;
      align-items: center;
      overflow: hidden;
      border: 1px solid rgba(255,255,255,0.1);
      box-sizing: border-box;
    }
    .bg-timeline-item.video {
      background: linear-gradient(135deg, #2a4a2a, #1a3a1a);
    }
    .bg-timeline-item.image {
      background: linear-gradient(135deg, #2a2a4a, #1a1a3a);
    }
    .bg-timeline-item.selected {
      border-color: #f90;
    }
    .bg-timeline-item .thumb {
      height: 100%;
      width: 100%;
      object-fit: cover;
      pointer-events: none;
      opacity: 0.7;
    }
    .bg-timeline-item .item-label {
      position: absolute;
      bottom: 2px;
      left: 4px;
      font-size: 9px;
      color: #fff;
      text-shadow: 0 0 3px #000;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: calc(100% - 8px);
    }
    .bg-timeline-item .resize-handle {
      position: absolute;
      width: 8px;
      height: 100%;
      cursor: ew-resize;
      background: rgba(255,153,0,0.3);
      opacity: 0;
      transition: opacity 0.2s;
    }
    .bg-timeline-item:hover .resize-handle {
      opacity: 1;
    }
    .bg-timeline-item .resize-handle.left { left: 0; border-radius: 4px 0 0 4px; }
    .bg-timeline-item .resize-handle.right { right: 0; border-radius: 0 4px 4px 0; }
    .bg-timeline-item.video .resize-handle {
      display: none;
    }
    .bg-timeline-item .delete-btn {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 16px;
      height: 16px;
      background: rgba(255, 60, 60, 0.6);
      border: none;
      border-radius: 50%;
      color: #fff;
      font-size: 10px;
      cursor: pointer;
      opacity: 0.5;
      transition: opacity 0.15s;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10;
    }
    .bg-timeline-item:hover .delete-btn {
      opacity: 1;
    }
    .bg-timeline-item .delete-btn:hover {
      background: rgba(255, 40, 40, 1);
    }

    .rev-gear-btn {
      position: absolute;
      top: 2px;
      right: 20px;
      width: 18px;
      height: 18px;
      background: rgba(255,255,255,0.15);
      border: none;
      border-radius: 3px;
      color: #ddd;
      font-size: 12px;
      cursor: pointer;
      z-index: 4;
      padding: 0;
      line-height: 18px;
      text-align: center;
    }
    .rev-gear-btn:hover {
      background: rgba(255,255,255,0.3);
      color: #fff;
    }
    .rev-popup {
      position: fixed;
      z-index: 9999;
      background: #1e1e1e;
      border: 1px solid #444;
      border-radius: 6px;
      padding: 8px 12px;
      min-width: 180px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.5);
      font-size: 12px;
      color: #ccc;
    }
    .rev-popup-title {
      font-size: 11px;
      color: #888;
      margin-bottom: 6px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    .rev-popup-row {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 5px;
      cursor: default;
    }
    .rev-popup-row input[type="range"] {
      flex: 1;
      height: 14px;
    }
    .rev-popup-row input[type="checkbox"] {
      width: 14px;
      height: 14px;
    }
    .rev-pop-hold-val {
      min-width: 28px;
      text-align: right;
      font-variant-numeric: tabular-nums;
    }
    .rev-popup-divider {
      margin-top: 4px;
      padding-top: 5px;
      border-top: 1px solid #333;
    }

    .bg-timeline-item .video-mode-select {
      position: absolute;
      bottom: 2px;
      left: 2px;
      font-size: 9px;
      padding: 1px 2px;
      background: rgba(0,0,0,0.7);
      color: #fff;
      border: 1px solid rgba(255,255,255,0.3);
      border-radius: 3px;
      cursor: pointer;
      z-index: 4;
      opacity: 0;
      transition: opacity 0.15s;
      max-width: 60px;
    }
    .bg-timeline-item:hover .video-mode-select {
      opacity: 1;
    }
    .bg-timeline-item .video-mode-badge {
      position: absolute;
      top: 2px;
      left: 2px;
      font-size: 10px;
      background: rgba(0,0,0,0.6);
      border-radius: 3px;
      padding: 0 3px;
      z-index: 3;
      pointer-events: none;
    }

    /* Sidebar Toggle Button (hidden on desktop) */
    .sidebar-toggle {
      display: none;
      position: fixed;
      top: 12px;
      left: 12px;
      z-index: 1001;
      width: 40px;
      height: 40px;
      border-radius: 8px;
      background: rgba(17,17,17,0.95);
      border: 1px solid #333;
      color: #fff;
      font-size: 20px;
      cursor: pointer;
      align-items: center;
      justify-content: center;
    }
    .sidebar-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.5);
      z-index: 999;
    }
    .sidebar-overlay.active { display: block; }

    /* Tablet: sidebar becomes slide-over overlay */
    @media (max-width: 1024px) {
      .sidebar-toggle { display: flex; }
      .app { grid-template-columns: 1fr; }
      canvas { touch-action: none; }
      .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 320px;
        min-width: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
      }
      .sidebar.sidebar-open {
        transform: translateX(0);
      }
      .sidebar-toggle.hidden { display: none; }
    }

    /* Mobile */
    @media (max-width: 768px) {
      .canvas-wrap { padding: 10px 8px 6px 8px; }
      canvas { max-height: 40vh; }
      .playback-controls { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
      .control-btn { width: 44px; height: 44px; }
      .playback-controls .track-info { flex-basis: 100%; order: -1; text-align: center; }
      .bottom-playlist-header { flex-wrap: wrap; gap: 6px; padding: 6px 12px; }
      .transition-controls { flex-basis: 100%; border-left: none; border-top: 1px solid #333; padding: 6px 0 0 0; }
      .sidebar { width: min(300px, 85vw); }
      .modal { width: 95vw; max-width: 95vw; }
    }

    /* Small phone */
    @media (max-width: 480px) {
      canvas { max-height: 35vh; }
      .timeline { height: 60px; padding: 6px 10px; }
      .bottom-playlist-item .drag-handle,
      .bottom-playlist-item .track-enhancement { display: none; }
      .bg-actions { flex-wrap: wrap; }
    }
