* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.title {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-secondary:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.3);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.2rem;
    position: relative;
    z-index: 1;
}

/* Compact Header Buttons */
#addNoteBtn {
    padding: 0.5rem 1rem;
}

.btn-tools {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    justify-content: center;
}

/* Tools Dropdown */
.tools-dropdown {
    position: relative;
    z-index: 1000;
}

.tools-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 150px;
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    gap: 0.25rem;
    animation: fadeIn 0.2s;
}

.tools-content.active {
    display: flex;
}

.tools-item {
    width: 100%;
    justify-content: flex-start;
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
}

.tools-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
}

/* View Mode Switcher */
.view-mode-switcher {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 12px;
}

.view-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    position: relative;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.view-btn.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.view-icon {
    font-size: 1.1rem;
}

.trash-badge {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -5px;
    right: -5px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
    z-index: 20;
}

/* Tab Bar */
.tab-bar {
    background: rgba(22, 33, 62, 0.6);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
}

.tabs-container {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    overflow-x: auto;
}

.tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.tab-name {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

.tab-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.tab-close:hover {
    background: rgba(220, 38, 38, 0.3);
    color: #fca5a5;
}

.btn-add-tab {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: #a5b4fc;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-add-tab:hover {
    background: rgba(99, 102, 241, 0.3);
    transform: scale(1.1);
}

/* View Sections */
.view-section {
    display: none;
    flex: 1;
    overflow: auto;
}

.view-section.active {
    display: flex;
    flex-direction: column;
}

/* Canvas Styles */
.canvas {
    flex: 1;
    position: relative;
    overflow: auto;
    padding: 2rem;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

/* Sticky Note Styles */
.sticky-note {
    position: absolute;
    width: 280px;
    min-height: 150px;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    cursor: move;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sticky-note:hover {
    transform: translateY(-4px) rotate(0deg) !important;
    box-shadow: var(--shadow-lg);
}

.sticky-note.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 1000;
}

.sticky-note.resizing {
    user-select: none;
}

/* Color Variants - Lighter Pastels for Contrast */
.sticky-note[data-color="yellow"] {
    background: linear-gradient(135deg, rgba(255, 249, 196, 0.95) 0%, rgba(255, 241, 118, 0.95) 100%);
    color: #1a1a2e;
}

.sticky-note[data-color="green"] {
    background: linear-gradient(135deg, rgba(200, 230, 201, 0.95) 0%, rgba(165, 214, 167, 0.95) 100%);
    color: #1a1a2e;
}

.sticky-note[data-color="orange"] {
    background: linear-gradient(135deg, rgba(255, 224, 178, 0.95) 0%, rgba(255, 204, 128, 0.95) 100%);
    color: #1a1a2e;
}

.sticky-note[data-color="red"] {
    background: linear-gradient(135deg, rgba(255, 205, 210, 0.95) 0%, rgba(239, 154, 154, 0.95) 100%);
    color: #1a1a2e;
}

/* Note Header */
.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.importance-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.priority-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.importance-indicator.clickable {
    cursor: pointer;
    transition: transform 0.2s;
}

.importance-indicator.clickable:hover {
    transform: scale(1.2);
}

.note-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.delete-btn:hover {
    background: rgba(220, 38, 38, 0.3);
}

/* Note Content */
.note-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: inherit;
    outline: none;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
    flex: 1;
    margin: 0 0.5rem;
    min-width: 0;
}

.note-title:focus {
    background: rgba(0, 0, 0, 0.05);
}

.note-content {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    border: none;
    background: transparent;
    color: inherit;
    outline: none;
    resize: none;
    flex: 1;
    padding: 0.5rem;
    border-radius: 8px;
    line-height: 1.6;
    min-height: 60px;
    transition: background 0.2s;
}

.note-content:focus {
    background: rgba(0, 0, 0, 0.05);
}

.note-title::placeholder,
.note-content::placeholder {
    color: rgba(0, 0, 0, 0.3);
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 0%, transparent 50%, rgba(0, 0, 0, 0.2) 50%);
    border-bottom-right-radius: 16px;
}

.resize-handle::after {
    content: '⋰';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    text-align: center;
}

/* Importance Grid */
.importance-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 250px;
}

.importance-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
}

.importance-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.importance-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.importance-text {
    font-weight: 600;
}

/* List View Styles */
.list-container {
    flex: 1;
    padding: 2rem;
    overflow: auto;
}

.notes-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(26, 26, 46, 0.6);
    border-radius: 16px;
}

.notes-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.notes-table th {
    background: rgba(99, 102, 241, 0.2);
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.notes-table th:first-child {
    border-top-left-radius: 16px;
}

.notes-table th:last-child {
    border-top-right-radius: 16px;
}

.notes-table tbody tr {
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.notes-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

.notes-table td {
    padding: 1rem 1.5rem;
    color: var(--text-primary);
}

.col-importance {
    width: 60px;
}

.col-title {
    width: 25%;
}

.col-content {
    width: auto;
}

.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.notes-table th.col-actions {
    text-align: right;
}

.importance-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    width: 32px;
    height: 32px;
}

.importance-badge .priority-icon {
    width: 20px;
    height: 20px;
}

.importance-badge.clickable {
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.importance-badge.clickable:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.importance-badge.critical {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

.importance-badge.high {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.importance-badge.medium {
    background: rgba(234, 179, 8, 0.2);
    color: #fde047;
}

.importance-badge.low {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.importance-badge.lowest {
    background: rgba(45, 212, 191, 0.2);
    color: #5eead4;
}

.content-preview {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.list-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn.edit {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.action-btn.edit:hover {
    background: rgba(99, 102, 241, 0.3);
}

.action-btn.delete {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Trash View Styles */
.trash-container {
    flex: 1;
    padding: 2rem;
    overflow: auto;
}

.trash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.trash-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
}

.trash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.trash-note {
    background: rgba(26, 26, 46, 0.6);
    border-radius: 16px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    opacity: 0.7;
    transition: all 0.3s;
}

.trash-note:hover {
    opacity: 1;
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.trash-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.trash-note-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.trash-note-content {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    max-height: 100px;
    overflow: hidden;
}

.trash-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn.restore {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.action-btn.restore:hover {
    background: rgba(34, 197, 94, 0.3);
}

.action-btn.permanent-delete {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.action-btn.permanent-delete:hover {
    background: rgba(220, 38, 38, 0.3);
}

/* Canvas Tag in List */
.canvas-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    margin-top: 0.3rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
    transition: all 0.2s ease;
}

.canvas-tag.clickable {
    cursor: pointer;
    background: rgba(99, 102, 241, 0.3);
}

.canvas-tag.clickable:hover {
    background: rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

/* Canvas Selector Popover */
.canvas-selector-popover {
    position: absolute;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    animation: fadeIn 0.2s;
}

.canvas-selector-item {
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
    width: 100%;
}

.canvas-selector-item:hover {
    background: rgba(255, 255, 255, 0.1);
}


/* Mobile Optimization */
@media (max-width: 768px) {

    /* Header Adjustments */
    .header {
        padding: 1rem;
    }

    .title {
        display: none;
        /* Hide title on mobile to save space */
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .btn span:not(.btn-icon) {
        display: none;
        /* Hide button text, show only icons if needed, or specific buttons */
    }

    /* Show text for specific critical buttons if space allows, or rely on icons */
    /* For now, let's keep icons only for Tools, but maybe Restore All needs text? 
       Let's stick to the plan: hide title, compact others. 
       Actually, `btn-icon` logic might be enough. 
       Let's specifically target the View/Filter controls if they get squished.
    */

    .view-controls {
        gap: 0.5rem;
    }

    .view-btn span {
        display: none;
        /* Icon only view tabs */
    }

    .view-btn {
        padding: 0.5rem;
    }

    /* Responsive List View - Stacked Cards */
    .notes-table,
    .notes-table thead,
    .notes-table tbody,
    .notes-table th,
    .notes-table tr,
    .notes-table td {
        display: block;
    }

    .notes-table thead {
        display: none;
        /* Hide table headers */
    }

    .notes-table tr {
        background: rgba(26, 26, 46, 0.6);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 1rem;
        padding: 1rem;
        position: relative;
    }

    .notes-table td {
        padding: 0.5rem 0;
        border: none;
        text-align: left;
    }

    /* Specific Column Adjustments */
    .col-importance {
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: auto;
        padding: 0;
    }

    .col-title {
        font-size: 1.1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        padding-right: 2rem;
        /* Space for importance badge */
    }

    .col-content {
        color: var(--text-secondary);
        font-size: 0.95rem;
        margin-bottom: 1rem;
        max-height: 100px;
        overflow: hidden;
    }

    .col-actions {
        border-top: 1px solid var(--border-color);
        padding-top: 1rem;
        display: flex;
        justify-content: flex-end;
    }

    /* Compact Trash Buttons */
    .trash-header .header-actions .btn {
        padding: 0.5rem;
    }

    .trash-header .header-actions .btn .btn-text {
        display: none;
    }

    /* Trash Grid on Mobile */
    .trash-grid {
        grid-template-columns: 1fr;
        /* Single column */
    }

    /* Dialogs/Modals */
    .modal-content {
        width: 90%;
        margin: 0 5%;
    }
}