:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(30, 41, 59, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.4);
    border-right: 1px solid var(--border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.folder-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.folder-item {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}

.folder-name {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.folder-item:hover .folder-actions {
    opacity: 1;
}

.folder-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.folder-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.container {
    flex-grow: 1;
    max-width: none;
    padding: 2rem 3rem;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 600;
}

.gradient-text {
    background: linear-gradient(90deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls {
    display: flex;
    gap: 1rem;
    flex-grow: 1;
    justify-content: flex-end;
}

#searchInput {
    background: var(--glass);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    color: var(--text);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
    outline: none;
    transition: all 0.3s ease;
}

#searchInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.password-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    border: 2px dashed var(--primary);
}

.drag-handle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    cursor: grab;
    padding: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.8rem;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.card:hover {
    transform: translateY(-5px);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    color: #818cf8;
    padding-right: 2rem;
}

.card pre {
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.last-edited {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-style: italic;
}

.copy-tag {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    cursor: pointer;
    border: 1px solid rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}

.copy-tag:hover {
    background: rgba(99, 102, 241, 0.4);
    color: white;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.small {
    padding: 4px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.btn-icon.delete:hover {
    color: #ef4444;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 4000;
    /* Increased to be above sidebar (2000) */
    align-items: center;
    justify-content: center;
}

/* ... (skipping unchanged content) ... */

/* Full View Modal */
.full-view-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Darker backdrop */
    z-index: 5000;
    /* Highest priority */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    /* Elegant easing */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 95%;
    max-width: 600px;
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid var(--border);
}

.modal-content.small-modal {
    max-width: 400px;
}

.glass {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
}

.form-group select option {
    background: var(--bg);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #10b981;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Sidebar Overlay on Mobile */
.sidebar {
    width: 280px;
    background: #111827;
    /* Darker background like Sidebar.png */
    border-right: 1px solid var(--border);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
}

.sidebar-header h3 {
    font-size: 1.5rem;
    color: var(--text);
    /* Brighter like the screenshot */
    font-weight: 600;
    letter-spacing: 2px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .container {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 2.5rem;
        width: 100%;
        margin-bottom: 2rem;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    #searchInput {
        max-width: none;
    }
}

/* Card Design Refinements */
.card {
    background: #1e293b;
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card h3 {
    color: #6366f1;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.card .last-edited {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Floating Add Button on Mobile */
@media (max-width: 768px) {
    #addBtn {
        position: fixed;
        bottom: 2rem;
        right: 2rem;
        padding: 1rem 2rem;
        box-shadow: 0 10px 20px rgba(99, 102, 241, 0.4);
        z-index: 100;
    }
}

/* Custom Tag Styles */
.card-details {
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    line-height: 1.7;
    /* Line Clamping */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-highlight {
    background: rgba(250, 204, 21, 0.4);
    color: #fef08a;
    padding: 1px 3px;
    border-radius: 3px;
}

.copy-plain {
    cursor: pointer;
    transition: color 0.2s;
}

.copy-plain:hover {
    color: var(--primary);
}

.custom-link {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px dashed #60a5fa;
    transition: all 0.2s;
}

.custom-link:hover {
    color: #93c5fd;
    border-bottom-style: solid;
}

.custom-mark {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.3), rgba(192, 132, 252, 0.3));
    padding: 2px 4px;
    border-radius: 3px;
}

.custom-h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.5rem 0;
    display: block;
}

.custom-h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.5rem 0;
    display: block;
}

.custom-h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.5rem 0;
    display: block;
}

/* Folder Checkboxes */
.folder-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.folder-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s;
}

.folder-checkbox:hover {
    background: rgba(99, 102, 241, 0.1);
}

.folder-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.tag-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.tag-help code {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

/* Picker List Styles */
.picker-controls {
    margin-bottom: 1rem;
}

#pickerSearch {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text);
    outline: none;
}

.picker-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0.5rem;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.picker-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.picker-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Extra Mobile Optimizations */
@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .password-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 1.5rem;
        border-radius: 15px;
    }
}

.folder-item.drag-over {
    background: rgba(99, 102, 241, 0.3);
    border: 1px dashed var(--primary);
    transform: scale(1.02);
}

/* Full View Modal */
.full-view-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Darker backdrop */
    z-index: 5000;
    /* Highest priority */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    /* Elegant easing */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.full-view-modal.active {
    opacity: 1;
    visibility: visible;
}

.full-view-content {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    padding: 3rem;
    border-radius: 32px;
    background: #1e293b;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.full-view-modal.active .full-view-content {
    transform: scale(1) translateY(0);
}

.close-full-view {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.full-view-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #818cf8;
    background: linear-gradient(90deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.large-details {
    font-size: 1.1rem;
    line-height: 1.8;
}

/* Card Uniformity */
.card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-details {
    flex-grow: 1;
    /* Pushes actions to the bottom */
}

/* Mobile Safe Areas & Optimization */
@media (max-width: 768px) {
    .sidebar {
        padding-top: max(2.5rem, env(safe-area-inset-top));
        padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
    }

    .container {
        padding-top: max(2rem, env(safe-area-inset-top));
        padding-bottom: max(5rem, env(safe-area-inset-bottom));
        /* More bottom padding for FAB */
    }

    .folder-actions {
        opacity: 1 !important;
        /* Always visible on mobile */
    }

    .folder-item {
        padding: 1rem;
        /* Larger touch target */
    }

    .btn-icon.small {
        padding: 8px;
        /* Easier to tap */
    }

    .full-view-content {
        padding: 2rem;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}