* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a0a;
    --bg-light: #141414;
    --bg-lighter: #1f1f1f;
    --text-white: #f5f5f5;
    --text-gray: #a0a0a0;
    --border-color: #2a2a2a;
    --accent: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-white);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

.screen.active {
    display: flex;
}

/* ===== LOGIN SCREEN ===== */
.login-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    padding: 20px;
}

.login-card {
    max-width: 400px;
    width: 100%;
    padding: 40px 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: cardSlideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card h1 {
    font-size: clamp(24px, 5vw, 32px);
    font-weight: 700;
    letter-spacing: 3px;
    margin-bottom: 8px;
    color: var(--text-white);
}

.subtitle {
    color: var(--text-gray);
    font-size: clamp(12px, 2vw, 13px);
    margin-bottom: 32px;
    letter-spacing: 1px;
}

input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 14px;
    background: rgba(31, 31, 31, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--text-white);
    font-size: 16px;
    margin-bottom: 16px;
    font-family: inherit;
    transition: all 0.25s ease;
}

input::placeholder {
    color: rgba(160, 160, 160, 0.5);
}

input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.8));
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1.5px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    margin-bottom: 12px;
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--text-gray);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.25);
}

.secondary-btn:active {
    transform: scale(0.98);
}

/* ===== APP LAYOUT ===== */
.app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, rgba(20, 20, 20, 0.95) 0%, rgba(20, 20, 20, 0.98) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 200;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.new-note-btn, .new-folder-btn {
    margin: 8px 16px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.8));
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 1.2px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.new-folder-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    margin-top: 0;
}

.new-note-btn:active, .new-folder-btn:active {
    transform: scale(0.98);
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px;
    -webkit-overflow-scrolling: touch;
}

.empty-message {
    padding: 12px;
    text-align: center;
    color: rgba(160, 160, 160, 0.5);
    font-size: 12px;
}

.folder-section {
    margin-bottom: 4px;
}

.folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.folder-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.folder-header.drag-over {
    background: rgba(100, 200, 255, 0.15);
    border: 2px solid rgba(100, 200, 255, 0.5);
    transform: scale(1.03);
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.3);
}

.folder-header:active {
    transform: scale(0.98);
}

.folder-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.folder-icon {
    font-size: 12px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
    color: var(--text-gray);
}

.folder-header.collapsed .folder-icon {
    transform: rotate(-90deg);
}

.folder-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-actions {
    display: none;
    gap: 4px;
    flex-shrink: 0;
}

.folder-header:hover .folder-actions {
    display: flex;
}

.folder-action-btn {
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 3px;
    color: var(--text-gray);
    font-size: 9px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.folder-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-white);
}

.folder-notes {
    padding-left: 20px;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.folder-notes.collapsed {
    max-height: 0;
}

/* ===== UNCATEGORIZED SECTION ===== */
.uncategorized-section {
    margin-top: 8px;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.uncategorized-section.drag-over {
    background: rgba(150, 100, 255, 0.15);
    border: 2px solid rgba(150, 100, 255, 0.5);
    box-shadow: 0 0 20px rgba(150, 100, 255, 0.3);
}

.uncategorized-header {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-gray);
    letter-spacing: 0.8px;
}

.note-item {
    padding: 10px 12px;
    margin-bottom: 2px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: move;
    transition: all 0.15s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: none;
}

.note-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.note-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
    background: rgba(255, 255, 255, 0.1);
}

.note-item.ghost-dragging {
    opacity: 0.8;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    transform: rotate(2deg);
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.note-item:active {
    transform: scale(0.98);
}

.note-item.active {
    background: rgba(255, 255, 255, 0.12);
}

.note-item-title {
    font-weight: 500;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    pointer-events: none;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-white);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    margin-bottom: 8px;
}

.settings-btn:active {
    transform: scale(0.98);
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-gray);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.logout-btn:active {
    transform: scale(0.98);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.95) 0%, rgba(15, 15, 15, 0.95) 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.empty-state-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    display: none;
}

@media (max-width: 768px) {
    .empty-state-header {
        display: block;
    }
}

.empty-state h2 {
    color: var(--text-gray);
    font-size: clamp(14px, 3vw, 16px);
    letter-spacing: 1px;
    font-weight: 500;
    text-align: center;
}

.hint-text {
    margin-top: 12px;
    font-size: 13px;
    color: rgba(160, 160, 160, 0.6);
    font-weight: 400;
    text-align: center;
}

.note-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.editor-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: transparent;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    color: #000;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.3);
    align-items: center;
    justify-content: center;
}

.menu-toggle svg {
    pointer-events: none;
    stroke: #000;
}

.menu-toggle:active {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.4);
}

.note-title-input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 700;
    color: var(--text-white);
    outline: none;
    font-family: inherit;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.note-title-input:focus {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.note-title-input::placeholder {
    color: rgba(160, 160, 160, 0.4);
}

.editor-actions {
    display: flex;
    gap: 8px;
}

.folder-select {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-white);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.8px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-select:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ===== FOLDER POPUP ===== */
.folder-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.folder-popup-overlay.active {
    display: flex;
}

.folder-popup {
    background: linear-gradient(135deg, rgba(25, 25, 25, 0.98) 0%, rgba(20, 20, 20, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popupSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.folder-popup h3 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
    color: var(--text-white);
}

.folder-option {
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
}

.folder-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateX(4px);
}

.folder-option:active {
    transform: scale(0.98);
}

.folder-option-icon {
    font-size: 16px;
}

.folder-option-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white);
}

.folder-option.no-folder {
    border-color: rgba(255, 255, 255, 0.15);
}

.folder-option.no-folder .folder-option-text {
    color: var(--text-gray);
}

.folder-popup-close {
    margin-top: 16px;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--text-gray);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.folder-popup-close:active {
    transform: scale(0.98);
}

#noteContent {
    flex: 1;
    padding: 20px;
    background: transparent;
    border: none;
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-white);
    resize: none;
    outline: none;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#noteContent::placeholder {
    color: rgba(160, 160, 160, 0.4);
}

.editor-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: right;
    background: linear-gradient(180deg, rgba(20, 20, 20, 0.5) 0%, rgba(20, 20, 20, 0.8) 100%);
    font-size: 12px;
    color: var(--text-gray);
    letter-spacing: 1px;
}

.icon-btn {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-white);
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.8px;
    font-family: inherit;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn.danger {
    border-color: rgba(255, 107, 107, 0.2);
    color: rgba(255, 160, 160, 0.7);
}

.icon-btn.danger:active {
    border-color: rgba(255, 107, 107, 0.6);
    background: rgba(255, 107, 107, 0.08);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(31, 31, 31, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== SIDEBAR OVERLAY (Mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
        background: rgba(20, 20, 20, 1);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .editor-header {
        padding: 12px;
        gap: 8px;
        background: transparent;
    }

    #noteContent {
        padding: 16px;
        font-size: 14px;
    }

    .editor-footer {
        padding: 10px 16px;
        font-size: 11px;
    }

    .icon-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 260px;
        background: rgba(20, 20, 20, 1);
    }

    .login-card {
        padding: 32px 24px;
    }

    .new-note-btn, .new-folder-btn {
        margin: 8px 12px;
        padding: 10px;
        font-size: 11px;
    }

    #noteContent {
        padding: 14px;
        font-size: 14px;
    }

    .editor-footer {
        padding: 8px 14px;
    }

    .menu-toggle {
        width: 40px;
        height: 40px;
    }
}
