:root {
    --bg-color: #121212;
    --dot-color: rgba(255, 255, 255, 0.08);
    --fab-color: #ffeb3b;
    --fab-hover: #fff59d;
    --text-primary: #1a1a1a;
    --text-muted: rgba(0, 0, 0, 0.5);
    --note-width: 180px;
    --note-height: 180px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Outfit', sans-serif;
    color: white;
    /* Create a dot grid pattern */
    background-image: radial-gradient(var(--dot-color) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
    background-position: 0 0;
    overscroll-behavior: none;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

#canvas {
    width: 100%;
    height: 100%;
    position: relative;
    touch-action: none; /* Prevent standard scrolling on the canvas */
}

#empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.3s ease;
    user-select: none;
}

#empty-state.hidden {
    opacity: 0;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(255,255,255,0.1));
}

#empty-state h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

#empty-state p {
    margin: 0;
    color: rgba(255,255,255,0.5);
    font-size: 16px;
}

/* Floating Action Button */
#fab {
    position: absolute;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background-color: var(--fab-color);
    color: #000;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255, 235, 59, 0.3);
    z-index: 10000;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s;
}

#fab:active {
    transform: scale(0.9);
}

#download-btn, #upload-btn, #bg-upload-btn, #help-btn {
    position: absolute;
    bottom: 32px;
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#download-btn {
    left: 32px;
}

#upload-btn {
    left: 96px;
}

#bg-upload-btn {
    left: 160px;
}

#help-btn {
    left: 224px;
}

#download-btn:active, #upload-btn:active, #bg-upload-btn:active, #help-btn:active {
    transform: scale(0.9);
}

#download-btn:hover, #upload-btn:hover, #bg-upload-btn:hover, #help-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: #222;
    padding: 24px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-weight: 600;
}

.modal-content p {
    color: rgba(255,255,255,0.8);
    line-height: 1.5;
    margin-bottom: 16px;
}

.modal-content p:last-child {
    margin-bottom: 0;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
}

/* Jot (Sticky Note) Container */
.jot {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--note-width);
    height: var(--note-height);
    /* Transform handles the X/Y translation */
    transform-origin: center center;
    will-change: transform;
}

/* Inner element handles visual styling, scaling, and shadows independently of drag */
.jot-inner {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s;
    overflow: hidden;
}

/* State when actively dragging */
.jot.dragging .jot-inner {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

.jot-header {
    height: 28px;
    background-color: rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 8px;
    cursor: grab;
    touch-action: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.jot-header:active {
    cursor: grabbing;
}

.jot-delete {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(0,0,0,0.1);
    border: none;
    color: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s;
}

.jot-delete:hover, .jot-delete:active {
    background-color: rgba(0,0,0,0.2);
    color: #000;
}

.jot-delete svg {
    width: 12px;
    height: 12px;
}

.jot textarea {
    flex: 1;
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    padding: 12px;
    font-family: 'Kalam', cursive;
    font-size: 20px;
    line-height: 1.4;
    color: var(--text-primary);
    outline: none;
    /* Allow native touch scrolling inside the textarea */
    touch-action: pan-y;
}

.jot textarea::placeholder {
    color: var(--text-muted);
}

/* Custom Scrollbar for Textareas */
.jot textarea::-webkit-scrollbar {
    width: 4px;
}
.jot textarea::-webkit-scrollbar-track {
    background: transparent;
}
.jot textarea::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

/* Animation for note spawn */
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
.jot-inner {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}