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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f0f0;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 28px;
    color: #e60023;
}

.filter-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

#kategorieFilter, #sortOrder {
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    background: #fff;
}

#kategorieFilter:hover, #sortOrder:hover {
    border-color: #bbb;
}

/* Masonry Grid */
.masonry-grid {
    display: flex;
    gap: 20px;
    margin: 30px 0;
    width: 100%;
    overflow: hidden;
}

.masonry-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.column-sentinel {
    height: 1px;
    visibility: hidden;
}

.masonry-item {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.masonry-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.masonry-item img {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
}

.masonry-item .no-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

.item-info {
    padding: 12px 16px;
}

.item-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.item-source {
    font-size: 12px;
    color: #767676;
    margin-bottom: 8px;
}

.item-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.category-tag {
    background: #e1e1e1;
    color: #333;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.category-tag.editable {
    cursor: pointer;
    transition: background 0.2s;
}

.category-tag.editable:hover {
    background: #d0d0d0;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #767676;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: 16px;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header-link {
    color: #e60023;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.modal-header-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
}

.modal-info {
    padding: 24px;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-description {
    font-size: 14px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 16px;
}

.modal-link {
    color: #e60023;
    text-decoration: none;
    word-break: break-all;
}

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

.modal-categories {
    margin-top: 20px;
}

.modal-categories h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.modal-categories,
.modal-kommentar,
.modal-actions {
    padding: 24px;
}

.modal-kommentar h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

#kommentarTextarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

#kommentarTextarea:focus {
    outline: none;
    border-color: #e60023;
}

.modal-actions {
    border-top: 1px solid #e1e1e1;
    display: flex;
    justify-content: flex-end;
}

.delete-btn {
    padding: 10px 20px;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.delete-btn:hover {
    background: #c82333;
}

.category-input-container {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

#categoryInput {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

#addCategoryBtn, #reprocessMailBtn, #recrawlWebsiteBtn {
    padding: 8px 16px;
    background: #e60023;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

#addCategoryBtn:hover, #reprocessMailBtn:hover, #recrawlWebsiteBtn:hover {
    background: #d0001f;
}

.category-suggestions {
    position: absolute;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    width: calc(100% - 100px);
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.category-suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
}

.category-suggestion-item:hover {
    background: #f0f0f0;
}

.modal-category-tag {
    background: #e60023;
    color: #fff;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
    margin-bottom: 8px;
}

.remove-category {
    cursor: pointer;
    font-weight: 700;
    font-size: 16px;
}

.remove-category:hover {
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 16px;
    }

    .masonry-grid {
        gap: 15px;
        margin: 15px 0;
    }

    .masonry-item {
        border-radius: 12px;
    }

    .modal-content {
        margin: 10% 10px;
        max-width: calc(100% - 20px);
    }

    h1 {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .masonry-grid {
        gap: 10px;
        margin: 10px 0;
    }

    .modal-content {
        margin: 5% 10px;
    }
}