:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --surface: #1e1e2e;
    --text: #f1f1f6;
    --text-muted: #9ca3af;
    --border: #2a2a3a;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --radius: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
}

#app { min-height: 100dvh; }

/* Screens */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* Loading */
#loading-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: pulse 2s ease-in-out infinite;
}
.loader .material-icons-outlined {
    font-size: 3rem;
    color: var(--primary);
}
.loader span:last-child {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Auth Screens */
#login-screen, #register-screen, #sync-screen, #new-sync-screen {
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}
.logo-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 8px;
}
.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Form */
.auth-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-group input::placeholder { color: var(--text-muted); opacity: 0.7; }

.password-input {
    position: relative;
}
.password-input input { padding-right: 48px; }
.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toggle-password .material-icons-outlined { font-size: 1.2rem; }
.toggle-password:hover { color: var(--text); }

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
    min-height: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}
.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(99,102,241,0.5);
    transform: translateY(-1px);
}
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn .material-icons-outlined { font-size: 1.1em; }

.auth-footer {
    text-align: center;
    margin-top: 24px;
}
.auth-footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.auth-footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
}
.auth-footer a:hover { text-decoration: underline; }

/* Strength Bar */
.strength-bar {
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
#strength-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}
.strength-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* Notes Screen */
#notes-screen { background: var(--bg); }

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-left h1 {
    font-size: 1.25rem;
    font-weight: 800;
}
.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.header-actions { display: flex; gap: 8px; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.icon-btn:hover { background: var(--bg-card); color: var(--text); border-color: var(--primary); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn .material-icons-outlined { font-size: 1.2rem; }

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.search-bar.hidden { display: none; }
.search-bar input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}
.search-bar input:focus { outline: none; border-color: var(--primary); }

/* Notes Content */
.notes-content {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
}

.notes-list {
    display: grid;
    gap: 12px;
}

.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.note-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--note-color, #6b7280);
}
.note-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.note-card-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.note-card-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.note-card-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.empty-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state.hidden, .loading-state.hidden { display: none; }
.empty-state .material-icons-outlined {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}
.empty-state h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text);
}
.loading-state .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--gradient);
    border-radius: 16px;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(99,102,241,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 32px rgba(99,102,241,0.5);
}
.fab .material-icons-outlined { font-size: 1.6rem; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal:not(.hidden) { display: flex; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
}
.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.modal-header input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
}
.modal-header input:focus { outline: none; }
.modal-header input::placeholder { color: var(--text-muted); }
.modal-actions { display: flex; gap: 8px; }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.modal-body textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 200px;
    line-height: 1.6;
}
.modal-body textarea:focus { outline: none; border-color: var(--primary); }
.modal-body textarea::placeholder { color: var(--text-muted); }

.category-picker { margin-top: 16px; }
.category-picker label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.category-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}
.chip:hover { border-color: var(--primary); }
.chip.active { border-color: var(--primary); background: rgba(99,102,241,0.15); }
.chip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.note-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

@media (min-width: 640px) {
    .modal { align-items: center; }
    .modal-content {
        border-radius: var(--radius);
        max-height: 80dvh;
    }
}
