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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    line-height: 1.6;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    margin-bottom: 24px;
    text-align: center;
    color: #1a1a1a;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 14px;
    color: #4a4a4a;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: #e5e7eb;
    color: #1a1a1a;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* App header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 24px;
    border-bottom: 2px solid #e5e7eb;
}

header h1 {
    font-size: 28px;
    color: #1a1a1a;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Cards */
.note-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 16px;
    transition: box-shadow 0.2s;
}

.note-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.note-header h3 {
    font-size: 18px;
    color: #1a1a1a;
}

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

.note-content {
    color: #4a4a4a;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.tag {
    background: #eef2ff;
    color: #4f46e5;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tag:hover {
    background: #c7d2fe;
}

.note-meta {
    font-size: 12px;
    color: #9ca3af;
}

/* Note editor */
.note-editor {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}

.note-editor h2 {
    margin-bottom: 16px;
    font-size: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Filters */
.filter-section {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.filter-section input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

/* Change password */
.change-password-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}

.change-password-card h3 {
    margin-bottom: 16px;
}

.error {
    color: #ef4444;
    padding: 10px 12px;
    background: #fee2e2;
    border-radius: 8px;
    margin-bottom: 16px;
}

.message {
    color: #22c55e;
    padding: 10px 12px;
    background: #dcfce7;
    border-radius: 8px;
    margin-top: 12px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

/* Responsive */
@media (max-width: 768px) {
    #app {
        padding: 12px;
    }
    
    header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        text-align: center;
    }
    
    .header-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .note-header {
        flex-direction: column;
        gap: 8px;
    }
    
    .note-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}
/* ==================== LAYOUT ==================== */
.main-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar h3 {
    margin-bottom: 16px;
    font-size: 16px;
    color: #1a1a1a;
}

.tags-list {
    list-style: none;
    padding: 0;
}

.tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    color: #4a4a4a;
}

.tag-item:hover {
    background: #eef2ff;
    color: #4f46e5;
}

.tag-item.active-tag {
    background: #6366f1;
    color: white;
    font-weight: 500;
}

.tag-item.active-tag .tag-count {
    background: rgba(255,255,255,0.25);
    color: white;
}

.tag-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-count {
    background: #e5e7eb;
    color: #6b7280;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    margin-left: 6px;
    flex-shrink: 0;
}

.empty-tags {
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

/* ==================== LINKS ==================== */
.auto-link {
    color: #4f46e5;
    text-decoration: none;
    background: linear-gradient(to bottom, transparent 60%, #c7d2fe 60%);
    padding: 0 2px;
    border-radius: 3px;
    transition: all 0.15s;
    word-break: break-all;
}

.auto-link:hover {
    color: #3730a3;
    background: #eef2ff;
    text-decoration: underline;
}

/* ==================== ENCRYPTION ==================== */
.checkbox-group {
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 0 !important;
    font-weight: 500;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #6366f1;
}

.encrypt-password-block {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.password-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.password-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.encrypted-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
}

.hint-text {
    color: #92400e;
    font-size: 12px;
    display: block;
    margin-top: 4px;
}

.error-text {
    color: #dc2626;
    font-size: 12px;
}

.lock-icon {
    margin-right: 6px;
}

.encrypted-content {
    margin-bottom: 12px;
}

.locked-content {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #6b7280;
}

.locked-content p {
    margin-bottom: 12px;
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h3 {
    margin-bottom: 12px;
}

.modal p {
    margin-bottom: 16px;
    color: #4a4a4a;
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
}

/* ==================== FILES ==================== */
.file-input {
    font-size: 14px;
    padding: 8px 0;
}

.pending-files {
    margin-top: 8px;
}

.pending-file {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #eef2ff;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #3730a3;
}

.btn-remove {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}

.btn-remove:hover {
    color: #b91c1c;
}

.note-files {
    margin: 12px 0;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 3px solid #6366f1;
}

.files-title {
    font-size: 13px;
    font-weight: 500;
    color: #4a4a4a;
    margin-bottom: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

.file-link {
    color: #4f46e5;
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-link:hover {
    text-decoration: underline;
}

.file-size {
    color: #9ca3af;
    font-size: 12px;
}

/* ==================== FILTER INFO ==================== */
.filter-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #eef2ff;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #3730a3;
}

.filter-info strong {
    color: #4f46e5;
}
/* ==================== TAGS INPUT (chips) ==================== */
.tags-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    cursor: text;
    min-height: 42px;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tags-input-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eef2ff;
    color: #4f46e5;
    padding: 3px 6px 3px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    user-select: none;
    transition: background 0.15s;
}

.tag-chip:hover {
    background: #c7d2fe;
}

.tag-chip-remove {
    background: transparent;
    border: none;
    color: #4f46e5;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.tag-chip-remove:hover {
    background: #4f46e5;
    color: white;
}

.tags-input {
    flex: 1;
    min-width: 120px;
    border: none;
    outline: none;
    padding: 4px 0;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: #1a1a1a;
}

.tags-input::placeholder {
    color: #9ca3af;
}

/* datalist в некоторых браузерах не стилизуется — оставим по умолчанию */

/* Подсказка нейтрального цвета */
.hint-text.neutral {
    color: #6b7280;
    font-size: 12px;
    margin-top: 6px;
    display: block;
}