* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: #f5f3e8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #222;
}

.notes-app {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
}

.app-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
}

.app-title {
    font-size: 24px;
    font-weight: 400;
    margin: 0;
    font-family: 'Iosevka SS14 Web', Georgia, serif;
    letter-spacing: 0.01em;
}

.app-count {
    font-size: 13px;
    color: #888;
    font-family: 'SF Mono', 'Menlo', monospace;
    flex: 1;
}

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: #8b7355;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.header-icon-btn:hover {
    background: #eceadf;
    color: #6b5a42;
}

/* Search */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 40px 12px 44px;
    font-size: 15px;
    border: 1px solid #e6e6e0;
    border-radius: 8px;
    background: #fffef8;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: 'Iosevka SS14 Web', monospace;
}

.search-input:focus {
    border-color: #b8a88a;
    box-shadow: 0 0 0 3px rgba(184, 168, 138, 0.15);
}

.clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #e6e6e0;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    background: #d8d8d0;
}

/* Tags section */
.tags-section {
    margin-bottom: 16px;
}

.tags-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.tags-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.clear-tags-btn {
    font-size: 12px;
    color: #8b7355;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.clear-tags-btn:hover {
    text-decoration: underline;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #e6e6e0;
    border-radius: 8px;
    background: #fffef8;
}

.tags-container.expanded {
    max-height: none;
}

.tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #f0ede4;
    border: 1px solid #e6e6e0;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: 'Iosevka SS14 Web', monospace;
    color: #555;
}

.tag-btn:hover {
    background: #e8e4d8;
    border-color: #d8d4c8;
}

.tag-btn.active {
    background: #8b7355;
    border-color: #7a6248;
    color: #fff;
}

.tag-btn.active:hover {
    background: #7a6248;
}

.tag-btn.filtered-out {
    display: none;
}

.tag-name {
    font-weight: 500;
}

.tag-count {
    font-size: 11px;
    opacity: 0.7;
}

/* Active filters */
.active-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fffef8;
    border: 1px solid #e6e6e0;
    border-radius: 8px;
    margin-bottom: 16px;
}

.filters-label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #8b7355;
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Iosevka SS14 Web', monospace;
}

.filter-chip-remove {
    cursor: pointer;
    opacity: 0.8;
    margin-left: 2px;
}

.filter-chip-remove:hover {
    opacity: 1;
}

/* Notes list */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.note-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.note-content {
    flex: 1;
    min-width: 0;
}

.note-edit-btn {
    flex-shrink: 0;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid #d8d4c8;
    border-radius: 4px;
    color: #888;
    font-size: 12px;
    font-family: 'SF Mono', 'Menlo', monospace;
    cursor: pointer;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.note-card:hover .note-edit-btn {
    opacity: 1;
}

.note-edit-btn:hover {
    background: #e8e4d8;
    color: #6b5a42;
    border-color: #c8c4b8;
}

.note-card:hover {
    background: #eceadf;
}

.note-card.hidden {
    display: none;
}

.note-title {
    font-size: 15px;
    font-weight: 400;
    margin: 0 0 4px 0;
    line-height: 1.3;
    font-family: 'Iosevka SS14 Web', Georgia, serif;
    color: #222;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #888;
}

.note-date {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 11px;
}

.note-tag {
    padding: 2px 6px;
    background: #e8e4d8;
    color: #6b5a42;
    border-radius: 3px;
    font-size: 11px;
    font-family: 'Iosevka SS14 Web', monospace;
}

.note-snippet {
    margin-top: 6px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.body-search-divider {
    width: 100%;
    padding: 12px 16px;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 1px solid #ddd;
    margin-top: 8px;
}

.body-search-result {
    opacity: 0.85;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #888;
}

.reset-btn {
    margin-top: 12px;
    padding: 10px 20px;
    background: #8b7355;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Iosevka SS14 Web', sans-serif;
}

.reset-btn:hover {
    background: #7a6248;
}

/* FAB group */
.fab-group {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;
}

.fab {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.fab-primary {
    background: #8b7355;
    color: #fff;
    box-shadow: 0 4px 12px rgba(139, 115, 85, 0.4);
}

.fab-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(139, 115, 85, 0.5);
}

.fab-secondary {
    width: 44px;
    height: 44px;
    background: #fffef8;
    color: #8b7355;
    border: 2px solid #8b7355;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.fab-secondary:hover {
    background: #f5f3e8;
    transform: scale(1.05);
}

.fab-letter {
    font-size: 18px;
    font-weight: 700;
    font-family: Georgia, serif;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: #fffef8;
    border-radius: 10px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e6e6e0;
}

.modal-title {
    font-size: 17px;
    font-weight: 500;
    margin: 0;
    font-family: 'Iosevka SS14 Web', Georgia, serif;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
}

.modal-close:hover {
    color: #555;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #e6e6e0;
    border-radius: 6px;
    outline: none;
    background: #fff;
    font-family: 'Iosevka SS14 Web', sans-serif;
}

.modal-input:focus {
    border-color: #b8a88a;
    box-shadow: 0 0 0 3px rgba(184, 168, 138, 0.15);
}

.modal-textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #e6e6e0;
    border-radius: 6px;
    outline: none;
    resize: vertical;
    font-family: 'Iosevka SS14 Web', monospace;
    background: #fff;
}

.modal-textarea:focus {
    border-color: #b8a88a;
    box-shadow: 0 0 0 3px rgba(184, 168, 138, 0.15);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e6e6e0;
}

.modal-btn {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-family: 'Iosevka SS14 Web', sans-serif;
}

.modal-btn-cancel {
    background: #f0ede4;
    color: #555;
}

.modal-btn-cancel:hover {
    background: #e8e4d8;
}

.modal-btn-save {
    background: #8b7355;
    color: #fff;
}

.modal-btn-save:hover {
    background: #7a6248;
}

.modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .notes-app {
        padding: 16px;
    }
    
    .app-title {
        font-size: 22px;
    }
    
    .tags-container {
        max-height: 180px;
    }
    
    .note-edit-btn {
        opacity: 1;
    }
}

@media (min-width: 700px) {
    .fab-group {
        right: max(24px, calc(50% - 326px));
    }
}
