:root {
    /* Light Theme (Mid-Century Minimalist) */
    --bg-color: #F5F1E8;
    --primary-accent: #6B8E8D;
    --secondary-accent: #D8A48F;
    --card-bg: #FFFFFF;
    --text-primary: #2E2E2E;
    --text-secondary: #6D6D6D;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --shadow-hover-color: rgba(0, 0, 0, 0.12);
    --grid-color: rgba(0,0,0,0.02);
    --btn-hover-bg: rgba(0,0,0,0.03);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --border-subtle: rgba(255, 255, 255, 0.4);
    --input-bg: rgba(255, 255, 255, 0.5);
    --input-focus-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(0, 0, 0, 0.15);
    --preview-bg: rgba(0, 0, 0, 0.03);
    --preview-border: rgba(0, 0, 0, 0.05);

    /* Light Theme Note Colors */
    --note-color-0: #FFFFFF;
    --note-color-1: #FDEEEA;
    --note-color-2: #EBF1F1;
    --note-color-3: #F7F6EE;
    --note-color-4: #E8ECEE;

    /* Fonts */
    --font-main: 'Inter', sans-serif;
}

[data-theme="dark"] {
    /* Dark Theme (Night Owl Inspired) */
    --bg-color: #011627;
    --primary-accent: #82AAFF; /* Night Owl Blue */
    --secondary-accent: #C792EA; /* Night Owl Purple */
    --card-bg: #0B2942; /* Slightly lighter than bg */
    --text-primary: #D6DEEB; /* Night Owl Text */
    --text-secondary: #5F7E97; /* Muted Night Owl Text */
    --shadow-color: rgba(0, 0, 0, 0.4);
    --shadow-hover-color: rgba(0, 0, 0, 0.6);
    --grid-color: rgba(255,255,255,0.02);
    --btn-hover-bg: rgba(255,255,255,0.05);
    --glass-bg: rgba(11, 41, 66, 0.95);
    --border-subtle: rgba(255, 255, 255, 0.05);
    --input-bg: rgba(0, 0, 0, 0.2);
    --input-focus-bg: rgba(0, 0, 0, 0.4);
    --input-border: rgba(255, 255, 255, 0.1);
    --preview-bg: rgba(0, 0, 0, 0.2);
    --preview-border: rgba(255, 255, 255, 0.05);

    /* Dark Theme Note Colors (Muted variations of Night Owl palette) */
    --note-color-0: #0B2942; /* Base card */
    --note-color-1: #2E1B3D; /* Muted Purple hue */
    --note-color-2: #162C3A; /* Muted Teal/Cyan hue */
    --note-color-3: #2A2A1A; /* Muted Yellow hue */
    --note-color-4: #2A1D24; /* Muted Coral/Red hue */
}

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

body {
    background-color: var(--bg-color);
    font-family: var(--font-main);
    color: var(--text-primary);
    overflow: hidden; /* We want the board to be exactly full screen without scrolling, dragging only inside */
    width: 100vw;
    height: 100vh;

    /* Subtle grid alignment in background */
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
    z-index: 1000;
}

.theme-toggle-btn:hover {
    color: var(--text-primary);
    background-color: var(--btn-hover-bg);
    border-color: var(--border-subtle);
    transform: scale(1.05);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

[data-theme="dark"] .icon-moon {
    display: none;
}
[data-theme="light"] .icon-sun {
    display: none;
}

.board-container {
    width: 100%;
    height: 100%;
    position: relative;
    /* Grid layout for initial state before dragging */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: min-content;
    gap: 24px;
    padding: 40px;
    align-items: start;
    overflow-y: auto; /* Allow scrolling if too many items and they aren't absolutely positioned yet */
}

/* When a card is dragged, we change its position to absolute.
   The board container needs to handle this. */

.note-card {
    background-color: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 16px var(--shadow-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: box-shadow 0.2s ease, transform 0.2s ease, opacity 0.3s ease;
    cursor: grab;

    /* Animation for appearance */
    animation: fadeInScale 0.3s ease-out forwards;

    /* Initially standard flex layout, but becomes absolute when dragged */
    position: relative;
    width: 280px; /* Fixed width for consistency */
    min-height: 200px;

    /* Subtle glassmorphism */
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    /* No borders unless subtle */
    border: 1px solid var(--border-subtle);
}

.note-card.dragging {
    cursor: grabbing;
    opacity: 0.9;
    box-shadow: 0 12px 32px var(--shadow-hover-color);
    transform: scale(1.02);
    z-index: 100;
}

.note-card:hover {
    box-shadow: 0 8px 24px var(--shadow-hover-color);
    transform: translateY(-2px);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.note-category-tags {
    display: flex;
    gap: 8px;
}

.color-tag {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-tag:hover {
    transform: scale(1.2);
}

.color-tag.active {
    border: 2px solid var(--text-primary);
}

.note-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease, transform 0.2s ease;
    padding: 4px;
    border-radius: 50%;
}

.btn-icon:hover {
    color: var(--text-primary);
    transform: scale(1.1);
    background-color: var(--btn-hover-bg);
}

.note-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-main);
    letter-spacing: 0.2px;
}

.note-body {
    font-size: 0.95rem;
    color: var(--text-secondary);
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-main);
    resize: none;
    min-height: 100px;
    line-height: 1.5;
    letter-spacing: 0.1px;
}

/* Focus highlighting */
.note-title:focus,
.note-body:focus {
    color: var(--text-primary);
}

/* Link / Image Previews */
.note-preview-container {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--preview-bg);
    border: 1px solid var(--preview-border);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.note-preview-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.note-preview-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--preview-border);
}

.note-preview-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.note-preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-preview-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-preview-url {
    font-size: 0.75rem;
    color: var(--primary-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* FAB Menu */
.fab-container {
    position: fixed;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
    z-index: 1000;
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.fab-container.active .fab-item {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.fab-container.active .fab-item:nth-child(1) { transition-delay: 0.1s; }
.fab-container.active .fab-item:nth-child(2) { transition-delay: 0.05s; }
.fab-container.active .fab-item:nth-child(3) { transition-delay: 0s; }

.fab-label {
    background-color: var(--card-bg);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.fab-icon-container {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--card-bg);
    color: var(--primary-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.fab-item:hover .fab-icon-container {
    transform: scale(1.1);
    background-color: var(--bg-color);
}

.floating-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary-accent);
    color: white;
    border: none;
    box-shadow: 0 8px 24px var(--shadow-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s ease, box-shadow 0.2s ease;
}

.floating-btn:hover {
    transform: scale(1.05) translateY(-2px);
    background-color: #5d7e7d;
    box-shadow: 0 12px 32px rgba(107, 142, 141, 0.3);
}

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

.fab-container.active .floating-btn {
    transform: rotate(45deg);
    background-color: var(--secondary-accent);
    box-shadow: 0 8px 24px rgba(216, 164, 143, 0.4);
}

/* Specific input styles for links and images */
.note-input-link,
.note-input-image {
    width: 100%;
    padding: 12px;
    border: 1px dashed var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    font-family: var(--font-main);
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.3s ease;
}

.note-input-link::placeholder,
.note-input-image::placeholder,
.note-title::placeholder,
.note-body::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.note-input-link:focus,
.note-input-image:focus {
    border-color: var(--primary-accent);
    background-color: var(--input-focus-bg);
}

.note-image-preview {
    width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    object-fit: contain;
    max-height: 200px;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .board-container {
        padding: 20px;
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    }

    .note-card {
        width: 100%; /* Full width on mobile if in grid */
    }

    .floating-btn {
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
    }
}
