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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background: #1a1a2e;
}

#moodboard {
    background: transparent;
    background-image:
        linear-gradient(to right, #e0e0e0 1px, transparent 1px),
        linear-gradient(to bottom, #e0e0e0 1px, transparent 1px);
    background-size: 50px 50px;
}

#moodboard.no-grid {
    background-image: none;
}

#viewport.dark-mode #moodboard.no-grid {
    background-image: none;
}

#viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: default;
    user-select: none;
    position: relative;
    background: #000000;
}

#viewport.dark-mode {
    background: #000000;
}

/* Empty state hint */
#empty-hint {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    user-select: none;
    z-index: 1;
}

#empty-hint.hidden {
    display: none;
}

#empty-hint p {
    font-size: 18px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
}

body:not(.dark-mode) #empty-hint p {
    color: rgba(0, 0, 0, 0.4);
}

#viewport.dark-mode #moodboard {
    background-image:
        linear-gradient(to right, #333333 1px, transparent 1px),
        linear-gradient(to bottom, #333333 1px, transparent 1px);
}

#viewport.panning {
    cursor: grab;
}

#viewport.panning:active {
    cursor: grabbing;
}

#moodboard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: 0 0;
    will-change: transform;
}

/* Logo */
#logo {
    position: fixed;
    top: 10px;
    left: 20px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    z-index: 1001;
    pointer-events: none;
    user-select: none;
}

body:not(.dark-mode) #logo {
    color: #000;
}

/* Help button - round icon style */
#help-btn {
    position: fixed;
    top: 10px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 1000;
}

#help-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#help-btn:active {
    transform: scale(0.95);
}

#help-btn .icon {
    display: block;
    line-height: 1;
    color: #000;
}

/* Menu button - hamburger */
#menu-btn {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 1000;
}

#menu-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#menu-btn:active {
    transform: scale(0.95);
}

#menu-btn .icon {
    display: block;
    line-height: 1;
}

/* Hand button */
#hand-btn {
    position: fixed;
    top: 130px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    z-index: 1000;
}

#hand-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#hand-btn:active {
    transform: scale(0.95);
}

#hand-btn.active {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#hand-btn .icon {
    display: block;
}

/* Help modal */
#help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#help-modal.hidden {
    display: none;
}

.help-content {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: #fff;
}

.help-content h2 {
    font-size: 18px;
    margin: 20px 0 15px 0;
    font-weight: 600;
}

.help-content h2:first-child {
    margin-top: 0;
}

.help-section {
    margin-bottom: 15px;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.help-item:last-child {
    border-bottom: none;
}

.help-item kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    font-family: monospace;
    white-space: nowrap;
}

.help-item strong {
    color: #4fc3f7;
}

.help-item span {
    color: rgba(255, 255, 255, 0.8);
}

#close-help {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: #4fc3f7;
    border: none;
    border-radius: 8px;
    color: #000;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#close-help:hover {
    background: #29b6f6;
}

/* Settings modal */
#settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#settings-modal.hidden {
    display: none;
}

.settings-content {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    max-width: 350px;
    width: 90%;
    color: #fff;
    position: relative;
}

.close-x-btn {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #4fc3f7;
    color: #000;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.close-x-btn:hover {
    background: #29b6f6;
    transform: scale(1.1);
}

.close-x-btn:active {
    transform: scale(0.95);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    user-select: none;
}

.setting-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#bg-color-picker {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.button-group button {
    flex: 1;
    padding: 12px;
    background: #4fc3f7;
    border: none;
    border-radius: 8px;
    color: #000;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.button-group button:hover {
    background: #29b6f6;
}

/* Image container */
.image-container {
    position: absolute;
    cursor: move;
    will-change: transform, left, top, width, height;
    user-select: none;
}

.image-container img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    user-select: none;
}

/* Selection box */
.selection-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid #4fc3f7;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(79, 195, 247, 0.3);
    display: none;
}

.image-container.selected .selection-box {
    display: block;
}

/* Resize handles */
.handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #4fc3f7;
    border: 2px solid #fff;
    border-radius: 2px;
    pointer-events: auto;
    z-index: 100;
}

.handle:hover {
    background: #29b6f6;
    transform: scale(1.2);
}

.handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* Mode toggle button */
#mode-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 1000;
}

#mode-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#mode-toggle-btn:active {
    transform: scale(0.95);
}

#mode-toggle-btn .icon {
    display: block;
    line-height: 1;
}

/* Sticky Notes */
.sticky-note {
    position: absolute;
    cursor: move;
    will-change: transform, left, top, width, height;
    user-select: none;
    z-index: 10;
}

.sticky-note-content {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
    padding: 12px;
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    resize: none;
    outline: none;
    user-select: text;
    cursor: text;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.sticky-note-content:not(:disabled):focus {
    box-shadow: 0 0 0 2px #4fc3f7, 2px 2px 12px rgba(0, 0, 0, 0.3);
    border-color: #4fc3f7;
}

.sticky-note-content:disabled {
    background: linear-gradient(135deg, #ffe082 0%, #ffd54f 100%);
    color: #555;
    cursor: move;
    pointer-events: none;
}

body:not(.dark-mode) .sticky-note-content {
    background: linear-gradient(135deg, #ffeb3b 0%, #fdd835 100%);
}

body:not(.dark-mode) .sticky-note-content:disabled {
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
}

.sticky-note.selected .selection-box {
    display: block;
}
