:root {
    --primary-color: #ffffff;
    --secondary-color: #eaeaea;
    --accent-color: #ff5722;
    --background-color: #fafafa;
    --text-color: #2d3436;
    --modal-bg: rgba(0, 0, 0, 0.85);
}

[data-theme="dark"] {
    --primary-color: #2d3436;
    --secondary-color: #3d3d3d;
    --background-color: #1e272e;
    --text-color: #dfe6e9;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    margin: 0;
    padding: 10px;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

#theme-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    background: var(--primary-color);
    border: 1px solid var(--secondary-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1001;
}

h1 {
    text-align: center;
    color: var(--accent-color);
    font-size: 1.8rem;
    margin: 20px 0;
}

.search-container {
    margin-bottom: 20px;
    padding: 0 5px;
}

#search-bar {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border: 1px solid var(--secondary-color);
    border-radius: 12px;
    background-color: var(--primary-color);
    color: var(--text-color);
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.filter-container {
    display: flex;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 10px 0;
    margin-top: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-container::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    flex: 0 0 auto;
    margin: 0 5px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid var(--accent-color);
    border-radius: 20px;
    background-color: transparent;
    color: var(--accent-color);
    white-space: nowrap;
}

.filter-btn.active {
    background-color: var(--accent-color);
    color: #fff;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

.result-item {
    position: relative;
    border: 1px solid var(--secondary-color);
    border-radius: 15px;
    overflow: hidden;
    background-color: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s;
}

.result-item:active {
    transform: scale(0.98);
}

.category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: var(--accent-color);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    z-index: 1;
    text-transform: uppercase;
}

.community-choice {
    position: absolute;
    top: 45px;
    right: 12px;
    background-color: #ffd700;
    color: #000;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.result-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background-color: #eee;
}

.result-item-content {
    padding: 15px;
}

.result-item-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.result-item-content p {
    font-size: 0.9rem;
    margin: 0 0 10px 0;
    opacity: 0.8;
}

.click-hint {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: bold;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
}

.modal-content {
    background-color: var(--primary-color);
    margin: 0;
    position: absolute;
    bottom: 0;
    width: 100%;
    max-height: 90%;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@media (min-width: 768px) {
    .modal-content {
        position: relative;
        margin: 50px auto;
        width: 90%;
        max-width: 800px;
        border-radius: 15px;
        bottom: auto;
        animation: none;
    }
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    z-index: 2100;
    background: rgba(0,0,0,0.3);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#modal-image-container {
    position: relative;
    height: 250px;
}

@media (min-width: 768px) {
    #modal-image-container { height: 400px; }
}

#modal-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-info {
    padding: 20px;
}

.action-btn {
    width: 100%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    margin-top: 10px;
}

.comment-section {
    padding: 20px;
    background-color: var(--primary-color);
}

#comment-display {
    margin-bottom: 20px;
}

.comment-item {
    background-color: var(--background-color);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    border-left: 5px solid var(--accent-color);
}

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

.comment-actions {
    display: flex;
    gap: 10px;
}

.comment-actions button {
    background: var(--secondary-color);
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
}

.comment-img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 10px;
    margin-top: 12px;
}

.comment-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.like-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
}

#comment-form input,
#comment-form textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--secondary-color);
    border-radius: 10px;
    background-color: var(--background-color);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 16px; /* Prevent auto-zoom on iOS */
}

.file-label {
    display: block;
    text-align: center;
    padding: 12px;
    background-color: var(--secondary-color);
    border-radius: 10px;
    margin-bottom: 10px;
    font-weight: bold;
}

.contact-section {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--secondary-color);
}

.contact-section input,
.contact-section textarea {
    width: 100%;
    max-width: none;
    font-size: 16px;
}