body {
    background: linear-gradient(90deg, cornflowerblue, rgb(143, 199, 246));
    /* Blue to Lighter Blue (no white) */
    margin: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    font-family: 'Quicksand', sans-serif;
}

#appContainer {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: stretch;
}

/* Dark Mode State */
body.dark-mode {
    background: #1a1a1a;
    /* Override gradient */
    color: #f0f0f0;
}

/* Global Buttons */
#addWindowBtn,
#darkModeBtn,
#addWindowBtn,
#darkModeBtn,
#collectionBtn,
#settingsBtn {
    position: fixed;
    top: 10px;
    z-index: 1000;
    --button-size: 40px;
    width: var(--button-size);
    height: var(--button-size);
    border-radius: 50%;
    background-color: #ffffffcc;
    color: #333;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    transition: transform 0.2s, background-color 0.2s;
}

#addWindowBtn {
    right: 10px;
}

#darkModeBtn {
    right: 60px;
}

#collectionBtn {
    right: 110px;
}

#settingsBtn {
    right: 160px;
    display: none;
    /* Hidden by default, shown when image is loaded */
}

#addWindowBtn:hover,
#darkModeBtn:hover,
#collectionBtn:hover {
    background-color: #fff;
    transform: scale(1.1);
}

#collectionPanel {
    position: fixed;
    top: 10px;
    right: -320px;
    /* Hidden */
    width: 280px;
    height: calc(100% - 20px);
    /* Floating look */
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    padding: 16px;
    box-sizing: border-box;
}

body.dark-mode #collectionPanel {
    background: rgba(40, 40, 40, 0.85);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#collectionPanel.open {
    right: 10px;
}

#collectionPanel h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 600;
}

#collectionList {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 10px;
}

/* Scrollbar styling for list */
#collectionList::-webkit-scrollbar {
    width: 60px;
}

#collectionList::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

body.dark-mode #collectionList::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
}

.collection-item-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    background: #fff;
    border: 2px solid transparent;
}

.collection-item-container:hover {
    transform: scale(1.02);
}

.collection-item {
    width: 100%;
    display: block;
    cursor: grab;
}

.collection-item:active {
    cursor: grabbing;
}

.quick-paste-btn {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 122, 204, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}

.collection-item-container:hover .quick-paste-btn {
    opacity: 1;
    transform: scale(1);
}

.quick-paste-btn:hover {
    background: #005f9e;
    transform: scale(1.1);
}

#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#toast.show {
    opacity: 1;
}

#magnifier {
    position: fixed;
    border-radius: 12px;
    border: 3px solid #333;
    pointer-events: none;
    z-index: 5000;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    background-color: white;
}

.window {
    flex: 1;
    position: relative;
    background-color: transparent;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 2px solid #000;
}

.window:last-child {
    border-right: none;
}

.window:last-child .close-btn {
    right: 160px;
}

.window canvas {
    flex: 1;
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 100;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
  padding: 0;
}

.close-btn:hover {
  background: rgba(255, 0, 0, 0.8);
  transform: scale(1.1);
}

/* Custom Slider Styling */
.custom-slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    width: 100%;
    height: 24px;
    /* Touch target height */
    position: relative;
}

/* Track */
.custom-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    /* Linear gradient to simulate filled track */
    background: linear-gradient(to right,
            var(--thumb-color, #ff0000) 0%,
            var(--thumb-color, #ff0000) var(--track-fill-percent, 0%),
            rgba(255, 255, 255, 0.2) var(--track-fill-percent, 0%),
            rgba(255, 255, 255, 0.2) 100%);
    border-radius: 3px;
    cursor: pointer;
}

/* Thumb */
.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    /* Dynamic variables set by JS */
    width: var(--thumb-size, 16px);
    height: var(--thumb-size, 16px);
    background: var(--thumb-color, #ff0000);

    border-radius: 50%;
    border: 2px solid white;
    cursor: grab;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);

    /* Vertically center thumb on track (track is 6px height) */
    /* margin-top = (trackHeight - thumbHeight) / 2 */
    margin-top: calc((6px - var(--thumb-size, 16px)) / 2);

    transition: width 0.1s, height 0.1s, background-color 0.1s;
}

.custom-slider:active::-webkit-slider-thumb {
    cursor: grabbing;
}