/* ==========================================================================
   1. Font Imports
   ========================================================================== */
   @font-face {
    font-family: "Departure Mono";
    src: url("../assets/fonts/DepartureMono-Regular.woff2") format("woff2"),
         url("../assets/fonts/DepartureMono-Regular.woff") format("woff");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
  }
  
  /* ==========================================================================
     2. Global Styles & Resets
     ========================================================================== */
  * {
    box-sizing: border-box;
  }
  
  html,
  body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    font-family: "Departure Mono", monospace;
  }
  
  button,
  input,
  .modal-content {
    border-radius: 8px;
    font-family: "Departure Mono", monospace;
  }
  
  button {
    cursor: pointer;
    transition: background 0.3s, color 0.3s, border-color 0.3s, opacity 0.3s;
  }
  
  /* ==========================================================================
     3. Layout Structure
     ========================================================================== */
  .title-header {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    color: #e0e0e0;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
  }
  
  .canvas-container {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 200px;
    right: 250px;
    background: #121212;
    outline: none;
    cursor: crosshair;
    overflow: hidden;
  }
  
  #pixelCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }
  
  #previewCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }
  
  .left-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 200px;
    background: #1b1b1b;
    color: #e0e0e0;
    padding: 10px;
    z-index: 200;
    display: flex;
    flex-direction: column;
  }

/* App version label */
.app-version {
  font-family: "Departure Mono", monospace;
  font-size: 0.7rem;
  color: #a8a8a8;
  margin-top: 6px;
  letter-spacing: 0.5px;
}
  
  .right-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 250px;
    display: flex;
    flex-direction: row;
    z-index: 200;
  }
  
  .controls-vertical {
    width: calc(100% - 60px);
    min-width: 0;
    background: #1b1b1b;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
  }
  
  .tools-vertical {
    width: 60px;
    background: #262626;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    flex-shrink: 0;
  }
  
  /* ==========================================================================
     4. Components
     ========================================================================== */
  
  /* --------------------------------------------------------------------------
     4.1 Buttons, Links & Icons
     -------------------------------------------------------------------------- */
  .save-load button,
  .filter-btn,
  .export-controls button,
  #addLayerBtn {
    background: #242424;
    color: #e0e0e0;
    border: 1px solid #333;
    padding: 8px;
    width: 100%;
    font-family: "Departure Mono", monospace;
    border-radius: 4px;
  }
  
  .save-load button:hover,
  .filter-btn:hover,
  .export-controls button:hover,
  #addLayerBtn:hover {
    background: #2f2f2f;
  }
  
  .save-load button {
    flex: 1 1 auto;
    width: auto;
  }
  
  .filter-btn {
    margin-bottom: 0px;
  }
  
  .export-controls button {
    padding: 10px;
  }
  
  .tool-button {
    width: 36px;
    height: 36px;
    background: #242424;
    color: #e0e0e0;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #333;
    font-size: 1rem;
    border-radius: 4px;
    position: relative;
  }
  
  .tool-button.active {
    background: #2979ff;
    color: #fff;
  }
  
  /* Canvas Resize Tool */
  .canvas-resize-marquee {
    position: absolute;
    box-sizing: border-box;
    border: 2px dashed #3498db;
    z-index: 100;
    pointer-events: none;
    display: block;
  }

  .resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #3498db;
    border: 1px solid #ffffff;
    border-radius: 0;
    z-index: 101;
    pointer-events: all;
    box-sizing: border-box;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
  }

  /* Position the handles properly on the edges */
  .resize-handle.topLeft { 
    cursor: nwse-resize; 
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
  }
  .resize-handle.topCenter { 
    cursor: ns-resize; 
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .resize-handle.topRight { 
    cursor: nesw-resize; 
    top: 0;
    right: 0;
    transform: translate(50%, -50%);
  }
  .resize-handle.middleLeft { 
    cursor: ew-resize; 
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
  }
  .resize-handle.middleRight { 
    cursor: ew-resize; 
    top: 50%;
    right: 0;
    transform: translate(50%, -50%);
  }
  .resize-handle.bottomLeft { 
    cursor: nesw-resize; 
    bottom: 0;
    left: 0;
    transform: translate(-50%, 50%);
  }
  .resize-handle.bottomCenter { 
    cursor: ns-resize; 
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 50%);
  }
  .resize-handle.bottomRight { 
    cursor: nwse-resize; 
    bottom: 0;
    right: 0;
    transform: translate(50%, 50%);
  }
  
  /* Tool Flyout Menu */
  
  .tool-button-group-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: -12px;
  }
  
  .tool-group-flyout-trigger {
    width: 12px;
    font-size: 0.7em;
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }
  
  .tool-group-active-shape {
    border-left: 1px solid #333;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }
  
  .tool-flyout {
    display: none;
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 5px;
    background-color: #262626;
    border: 1px solid #333;
    border-radius: 4px;
    z-index: 10;
    width: 160px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 2px 0;
  }
  
  .tool-flyout.visible {
    display: flex;
    flex-direction: column;
  }
  
  .tool-flyout .flyout-item {
    width: 100%;
    height: 32px;
    padding: 0 8px;
    margin-bottom: 0;
    border-radius: 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 0.75rem;
    color: #e0e0e0;
    cursor: pointer;
  }
  
  .tool-flyout .flyout-item:hover {
    background-color: #383838;
  }
  
  .tool-flyout .flyout-item > i {
    margin-right: 8px;
    font-size: 1rem;
    width: 16px;
    text-align: center;
  }
  
  .flyout-item-label {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .flyout-item-shortcut {
    margin-left: 8px;
    color: #888;
    font-size: 0.8rem;
  }
  
  .tool-flyout .flyout-item.active {
    background-color: #2979ff;
    color: #fff;
  }
  .tool-flyout .flyout-item.active .flyout-item-shortcut {
    color: #ccc;
  }
  
  /* End of Tool Flyout */
  
  .layer-visibility-icon {
    width: 13px;
    text-align: center;
    cursor: pointer;
    color: #ccc;
    flex-shrink: 0;
    font-size: 0.6em;
  }
  
  .layer-visibility-icon:hover {
    color: #fff;
  }
  
  .layer-visibility-icon.fa-eye-slash {
    color: #2979ff;
  }
  
  .delete-btn {
    cursor: pointer;
    color: #e0e0e0;
    display: none;
    flex-shrink: 0;
    padding: 0 4px;
    font-size: 0.9em;
  }
  
  .layer-item:hover .delete-btn {
    display: inline;
  }
  
  .close-modal-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    cursor: pointer;
  }
  
  .import-actions button {
    flex: 1;
    padding: 10px;
    background: #242424;
    color: #e0e0e0;
    border: 1px solid #333;
    font-family: "Departure Mono", monospace;
    font-weight: 700;
    border-radius: 4px;
  }
  
  .import-actions button:hover {
    background: #2f2f2f;
  }
  
  .filter-overlay button {
    width: 100%;
    padding: 10px;
    background: #2979ff;
    border: none;
    color: #fff;
    font-weight: 700;
    border-radius: 4px;
    margin-top: 10px;
  }
  
  .filter-overlay button:hover {
    background: #1e5fdb;
  }
  
  .load-card .delete-board-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #242424;
    border: none;
    color: #e0e0e0;
    font-weight: 700;
    border-radius: 4px;
    padding: 5px 8px;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
  }
  
  .load-card:hover .delete-board-btn {
    opacity: 1;
    pointer-events: auto;
  }
  
  /* --------------------------------------------------------------------------
     4.2 Inputs & Controls (Sliders, Toggles)
     -------------------------------------------------------------------------- */
  .control-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
  }
  
  .control-group label {
    color: #e0e0e0;
    font-size: 0.9rem;
    margin-bottom: 5px;
  }
  
  input[type="number"] {
    padding: 6px;
    border: 1px solid #333;
    background: #2f2f2f;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: "Departure Mono", monospace;
    width: 100%;
    box-sizing: border-box;
  }
  
  .import-field input[type="number"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #444;
  }
  
  #pickerHexInput {
    min-width: 0;
    width: 75%;
    padding: 6px;
    border: 1px solid #333;
    background: #2f2f2f;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: "Departure Mono", monospace;
    text-align: center;
    text-transform: uppercase;
    box-sizing: border-box;
    margin: 0;
    outline: none;
  }
  
  #opacityInput {
    min-width: 0;
    width: 35%;
    padding: 6px 4px;
    border: 1px solid #333;
    background: #2f2f2f;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: "Departure Mono", monospace;
    text-align: center;
    -moz-appearance: textfield;
    outline: none;
  }
  
  #opacityInput::-webkit-outer-spin-button,
  #opacityInput::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  
  #pickerHexInput:focus,
  #opacityInput:focus {
    border-color: #2979ff;
    box-shadow: 0 0 3px #2979ff;
  }
  
  .filter-overlay .slider-group {
    margin-bottom: 15px;
  }
  
  .filter-overlay .slider-group label {
    display: block;
    color: #e0e0e0;
    font-size: 0.9rem;
    margin-bottom: 5px;
  }
  
  .filter-overlay input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 5px;
    height: 5px;
    outline: none;
    margin-top: 5px;
    margin-bottom: 15px;
  }
  
  .filter-overlay input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #2979ff;
    cursor: pointer;
  }
  
  .filter-overlay input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #2979ff;
    cursor: pointer;
    border: none;
  }
  
  .switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    vertical-align: middle;
    margin: 0;
    padding: 0;
  }
  
  .switch input {
    opacity: 0;
    width: 0;
    height: 0;
  }
  
  .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: 0.4s;
    border-radius: 20px;
  }
  
  .slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 50%;
  }
  
  .switch input:checked + .slider {
    background-color: #2979ff;
  }
  
  .switch input:checked + .slider:before {
    transform: translateX(20px);
  }
  
  .modal-content.import-content .import-options .slider-group {
    margin-bottom: 0;
  }
  
  #toleranceValueSpan {
    display: inline-block;
    min-width: 2em;
    text-align: right;
    font-weight: bold;
  }
  
  .modal-content.import-content input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 5px;
    height: 5px;
    outline: none;
    margin-top: 5px;
    margin-bottom: 10px;
  }
  
  .modal-content.import-content input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #2979ff;
    cursor: pointer;
  }
  
  .modal-content.import-content input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #2979ff;
    cursor: pointer;
    border: none;
  }
  
  /* --------------------------------------------------------------------------
     4.3 Panels & Subsections
     -------------------------------------------------------------------------- */
  
  .save-load {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
    flex-shrink: 0;
  }
  
  .minimap-section {
    margin-bottom: 5px;
    flex-shrink: 0;
  }
  
  .minimap {
    width: 100%;
    height: 180px;
    background: #1b1b1b;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
  }
  
  #minimapCanvas {
    display: block;
    width: 100%;
    height: 100%;
  }
  
  .layers-panel {
    background: #242424;
    padding: 10px;
    color: #e0e0e0;
    border-radius: 8px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
  }
  
  .layers-panel h3 {
    text-align: center;
    margin: 0 0 10px 0;
    font-size: 1rem;
    flex-shrink: 0;
  }
  
  #layersList {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
    overflow-y: auto;
    flex-grow: 1;
  }
  
  .layer-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #2f2f2f;
    padding: 5px 6px;
    margin-bottom: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s, opacity 0.3s, border-color 0.2s;
    border: 1px solid transparent;
    min-height: 35px;
    box-sizing: border-box;
  }
  
  .layer-lock-icon {
    width: 14px;
    text-align: center;
    cursor: pointer;
    color: #ccc;
    flex-shrink: 0;
    font-size: 0.6em;
  }
  
  .layer-lock-icon:hover {
    color: #fff;
  }
  
  .layer-lock-icon.fa-lock {
    color: #2979ff;
  }
  
  .layer-item.locked {
    opacity: 0.85;
  }
  
  .layer-item.active {
    background: rgba(41, 121, 255, 0.5);
    border-color: #2979ff;
  }
  
  .layer-item.hidden {
    opacity: 0.6;
  }
  
  .layer-name {
    flex-grow: 1;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .drop-indicator {
    position: absolute;
    height: 3px;
    background: #00afff;
    left: 5px;
    right: 5px;
    pointer-events: none;
    z-index: 10;
    display: none;
    border-radius: 1.5px;
  }
  
  .layer-item.multi-selected {
    outline: 2px dashed #00afff;
    outline-offset: -2px;
  }
  .layer-expand-icon {
    width: 5px;
    text-align: center;
    cursor: pointer;
    color: #ccc;
    flex-shrink: 0;
    font-size: 0.4em;
  }
  
  .layer-item-child {
    margin-left: 10px;
  }
  
  .grid-controls {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  
  .canvas-size-controls {
    margin-bottom: 10px;
  }
  
  .canvas-dimension-fields {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .dimension-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #2f2f2f;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 0 8px;
  }
  
  .dimension-input-wrapper:focus-within {
    border-color: #2979ff;
    box-shadow: 0 0 3px #2979ff;
  }
  
  .dimension-label {
    font-size: 0.65rem;
    color: #888;
    margin-right: 8px;
    font-family: "Departure Mono", monospace;
  }
  
  .dimension-input-wrapper input[type="number"] {
    flex-grow: 1;
    border: none;
    background: transparent;
    color: #e0e0e0;
    padding: 6px 0;
    font-size: 0.65rem;
    text-align: left;
    -moz-appearance: textfield;
    outline: none;
  }
  
  .dimension-input-wrapper input[type="number"]::-webkit-outer-spin-button,
  .dimension-input-wrapper input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  
  .lock-ratio button {
    width: 15px;
    height: 15px;
    padding: 0;
    margin: 0;
    background-color: transparent;
    border: 1px solid #2979ff;
    border-radius: 3px;
    color: #2979ff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }
  
  .lock-ratio button i {
    font-size: 0.5rem;
  }
  
  .lock-ratio button:hover {
    background-color: rgba(41, 121, 255, 0.1);
  }
  
  .lock-ratio button.active {
    color: #888;
    border-color: #444;
    background-color: transparent;
  }
  
  .lock-ratio button.active:hover {
    background-color: #3f3f3f;
  }
  
  .export-controls {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
  }
  
  .custom-color-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  
  .picker-panel {
    width: 100%;
    position: relative;
    cursor: crosshair;
  }
  
  #pickerPanelCanvas {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 0.8;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #ff0000;
  }
  
  .picker-hue {
    width: 100%;
    height: 15px;
    position: relative;
    cursor: ew-resize;
  }
  
  #pickerHueCanvas {
    display: block;
    width: 100%;
    height: 100%;
    border: 1px solid #444;
    border-radius: 4px;
  }
  
  .picker-indicator {
    position: absolute;
    pointer-events: none;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
  }
  
  #pickerPanelIndicator {
    width: 10px;
    height: 10px;
    top: 0%;
    left: 100%;
  }
  
  #pickerHueIndicator {
    width: 5px;
    height: calc(100% + 4px);
    border-radius: 1px;
    border-width: 1px;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    border-color: #333;
    background-color: #fff;
  }
  
  .color-display-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
  }
  
  .color-swatches {
    position: relative;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }
  
  .color-swatch {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px solid #555;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    box-sizing: border-box;
  }
  
  .color-swatch.foreground {
    top: 0;
    left: 0;
    z-index: 10;
    background-color: #ffffff;
  }
  
  .color-swatch.background {
    top: 6px;
    left: 6px;
    z-index: 5;
    cursor: pointer;
    background-color: #000000;
  }
  
  .color-history {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
    gap: 4px;
    margin-top: 0; /* Removed margin-top to prevent stacking with separator margin */
  }
  
  .color-history .swatch {
    width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    border: 1px solid #333;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    border-radius: 3px;
    background: #2f2f2f;
  }
  
  .color-history .swatch:hover {
    transform: scale(1.1);
  }
  
  .color-history .swatch.active {
    border-color: #2979ff;
    box-shadow: 0 0 4px #2979ff;
  }
  
  /* --------------------------------------------------------------------------
     4.4 Modals (Base, Load, Import, Filter Overlay)
     -------------------------------------------------------------------------- */
  .modal {
    display: none;
    position: fixed;
    z-index: 300;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow: auto;
  }
  
  .modal-content {
    margin: 10% auto;
    padding: 20px;
    background: #1b1b1b;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
  }
  
  .modal-content.large-modal {
    width: clamp(80%, 1100px, 95%);
    max-width: 1100px;
    height: clamp(70%, 700px, 90%);
    max-height: 700px;
    margin: 3% auto;
    display: flex;
    flex-direction: column;
  }
  
  #loadListContainer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
    overflow-y: auto;
    flex-grow: 1;
    padding: 5px;
  }
  
  .load-card {
    background: #2f2f2f;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;
    position: relative;
    transition: background 0.3s;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
  }
  
  .load-card:hover {
    background: #393939;
  }
  
  .load-card img {
    width: 100%;
    max-height: 150px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    margin: 0 auto 10px;
    background-color: #111;
  }
  
  .load-card .card-title {
    font-size: 1rem;
    text-align: center;
    margin-bottom: 5px;
    margin-top: auto;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .modal-content.import-content {
    width: clamp(300px, 460px, 90%);
  }
  
  .modal-content.import-content h3 {
    margin: 0 0 20px;
    font-size: 1.2rem;
    text-align: center;
    color: #e0e0e0;
  }
  
  .import-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }
  
  .import-field {
    display: flex;
    flex-direction: column;
  }
  
  .import-field label {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 5px;
  }
  
  .import-options {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  
  .option {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .option label {
    font-size: 0.9rem;
    color: #ccc;
    margin: 0;
  }
  
  .import-options .import-field {
    margin-top: 5px;
  }
  
  .import-actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
  }
  
  .filter-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1b1b1b;
    border-radius: 0;
    padding: 20px;
    z-index: 500;
    box-sizing: border-box;
    flex-direction: column; /* Changed from display: flex; to flex-direction to make it part of flex context if parent is flex */
    color: #e0e0e0;
  }
  
  .filter-overlay h3 {
    margin: 0 0 20px;
    text-align: center;
    font-size: 1.2rem;
    color: #e0e0e0;
    flex-shrink: 0;
  }
  
  .filter-sliders-container { /* This was added in HTML */
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px; /* For scrollbar */
  }
  
  .filter-overlay .slider-group { /* This is for individual slider groups */
    margin-bottom: 15px;
    flex-shrink: 0; /* Prevent shrinking if inside a flex column */
  }
  
  .filter-overlay .filter-actions { /* This was added in HTML for buttons */
    margin-top: auto; /* Pushes buttons to the bottom */
    flex-shrink: 0;
    padding-top: 10px; /* Some space above buttons */
  }
  
  /* --------------------------------------------------------------------------
     4.5 Tool-Specific UI (Tooltip, Selection, Move Overlay)
     -------------------------------------------------------------------------- */
  .eyedropper-tooltip {
    display: none;
    position: absolute;
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  }
  
  .selection-rectangle {
    position: absolute;
    border: 1px dashed #3498db;
    background: rgba(52, 152, 219, 0.1);
    pointer-events: none;
    z-index: 400;
    box-sizing: border-box;
  }
  
  #moveOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 450;
  }
  
  #moveOverlay .move-overlay-cell {
    position: absolute;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }
  
  .action-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: "Departure Mono", monospace;
    white-space: nowrap;
    z-index: 1100;
    pointer-events: none;
    transform: translate(15px, 10px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
  
  /* ==========================================================================
     5. Animations & Utilities
     ========================================================================== */
  .save-animation {
    animation: saveWave 0.8s ease-out;
  }
  
  @keyframes saveWave {
    0% {
      box-shadow: 0 0 0 rgba(255, 255, 255, 0.7);
    }
    25% {
      box-shadow: 0 0 8px rgba(255, 0, 255, 0.9);
    }
    50% {
      box-shadow: 0 0 16px rgba(0, 255, 255, 0.9);
    }
    75% {
      box-shadow: 0 0 8px rgba(255, 255, 0, 0.9);
    }
    100% {
      box-shadow: 0 0 0 rgba(255, 255, 255, 0.7);
    }
  }
  
  .layer-item.drop-inside {
    background-color: #4a4a4a;
  }
  
  .layer-item.dragging {
    opacity: 0.5;
    background: #555;
  }

  /* Make the crop tool button active state visible */
  #toolCrop.active {
    background-color: rgba(52, 152, 219, 0.3);
    box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.8);
  }

  /* ==========================================================================
     6. Tool Options Panel
     ========================================================================== */
  
  .tool-options-separator {
    height: 1px;
    background: #333;
    margin: 0 0 10px 0; 
  }
  
  .tool-options-panel {
    background: none; /* Removed background to let it float */
    padding: 0; /* Removed padding */
    margin-bottom: 0; /* Removed margin */
    color: #e0e0e0;
    border-radius: 0; /* Removed border radius */
    display: none; /* Hidden by default, shown when tool has options */
  }

  .tool-options-panel.visible {
    display: block;
  }

  .tool-options-title {
    display: none; /* Hide title as per new design */
  }

  .tool-options-content {
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove default gap, we'll add specific spacing */
  }

  /* Tool option groups with specific spacing */
  .tool-option-group {
    display: flex;
    flex-direction: column;
    gap: 4px; /* Reduced gap */
  }

  .tool-option-group-label {
    font-size: 0.65rem; /* Reduced font size */
    color: #ccc;
    margin-bottom: 2px; /* Reduced margin */
    font-weight: 500;
  }

  /* Specific spacing for gradient type */
  .tool-option-group:first-child {
    margin-bottom: 10px; /* 10px between gradient type and next component */
  }

  /* Specific spacing for dithering style (second group) */
  .tool-option-group:nth-child(2) {
    margin-bottom: 15px; /* 15px between dithering style and advanced options */
  }

  /* Specific spacing for advanced options (third group) */
  .tool-option-group:nth-child(3) {
    margin-bottom: 10px; /* 10px below advanced options */
  }

  /* Button groups for tool options */
  .tool-option-buttons {
    display: flex;
    gap: 4px;
  }

  .tool-option-button {
    flex: 1;
    background: #2f2f2f;
    color: #e0e0e0;
    border: 1px solid #444;
    padding: 6px 8px; /* Reduced padding */
    font-size: 0.6rem; /* Reduced font size */
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px; /* Reduced gap */
  }

  .tool-option-button:hover {
    background: #383838;
    border-color: #555;
  }

  .tool-option-button.active {
    background: #2979ff;
    border-color: #2979ff;
    color: #fff;
  }

  .tool-option-button i {
    font-size: 0.9rem;
  }

  /* Dropdown for tool options */
  .tool-option-dropdown {
    background: #2f2f2f;
    color: #e0e0e0;
    border: 1px solid #444;
    padding: 6px; /* Reduced padding */
    border-radius: 4px;
    font-size: 0.6rem; /* Reduced font size */
    cursor: pointer;
    width: 100%;
  }

  .tool-option-dropdown:focus {
    border-color: #2979ff;
    outline: none;
    box-shadow: 0 0 3px #2979ff;
  }

  /* Toggle switches for tool options */
  .tool-option-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px; /* Reduced gap */
  }

  .tool-option-toggle-label {
    font-size: 0.6rem; /* Reduced font size */
    color: #e0e0e0;
    flex-grow: 1;
  }

  .tool-option-toggle-switch {
    position: relative;
    width: 32px; /* Slightly reduced size */
    height: 18px; /* Slightly reduced size */
    background: #444;
    border-radius: 9px; /* Adjusted border radius */
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
  }

  .tool-option-toggle-switch.active {
    background: #2979ff;
  }

  .tool-option-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px; /* Adjusted size */
    height: 14px; /* Adjusted size */
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
  }

  .tool-option-toggle-switch.active::after {
    transform: translateX(14px); /* Adjusted for new smaller size */
  }