:root {
    --primary-color: #3a2e2e;
    --secondary-color: #f4a261;
    --background-color: #fdfaf6;
    --card-bg-color: #ffffff;
    --text-color: #333;
    --border-color: #ddd;
    --global-avg-color: #2a9d8f;
    --user-rating-color: #2196f3;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
}

/* Loading / skeleton */
.item-loading {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    padding: 1rem;
}
.skeleton-card {
    background: linear-gradient(90deg, #eee 25%, #ddd 37%, #eee 63%);
    background-size: 400% 100%;
    border-radius: 8px;
    height: 140px;
    animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
    0% { background-position: 0% 0; }
    100% { background-position: -135% 0; }
}
.hidden { display:none !important; }

a {
    color: var(--secondary-color);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.logo, .logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}
.menu-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}
.mobile-nav {
    display: none;
    position: absolute;
    top: 60px;
    right: 20px;
    background-color: var(--primary-color);
    border-radius: 5px;
    overflow: hidden;
    z-index: 100;
}
.mobile-nav.show { display: block; }
.mobile-nav a {
    display: block;
    padding: 1rem;
    color: white;
    text-decoration: none;
}
.mobile-nav a:hover { background-color: #5c4a4a; }

main { padding: 2rem; }
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.filters {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}
#search-input, #sort-select, input[type="date"] {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

/* Rating Modal Slider Styles */
.rating-field {
    margin-bottom: 1.5rem; /* Add space between sliders */
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px; /* Taller track */
    background: #e0e0e0;
    border-radius: 6px;
    outline: none;
    margin-top: 8px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px; /* Bigger thumb */
    height: 24px; /* Bigger thumb */
    background: var(--secondary-color);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 24px; /* Bigger thumb */
    height: 24px; /* Bigger thumb */
    background: var(--secondary-color);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

/* Hide thumb on disabled display sliders to avoid confusion */
.slider-wrapper input[type=range]:disabled::-webkit-slider-thumb {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}
.slider-wrapper input[type=range]:disabled::-moz-range-thumb {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}


.item-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
    display: flex;
    flex-direction: column;
}
.item-card-summary {
    padding: 1rem;
}
.item-card h3 { margin-top: 0; }
.item-card .overall-rating {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--secondary-color);
}
.tracknrated-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--secondary-color);
    color: white;
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    font-size: 0.8rem;
}
.item-card-actions {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: auto;
}

.item-card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
    padding: 0 1rem;
}
.item-card.expanded .item-card-details {
    max-height: 1000px;
    padding-bottom: 1rem;
}
.rating-slider-display .marker {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
    pointer-events: auto;
    cursor: help;
}
.global-avg-marker { background-color: var(--global-avg-color); }
.user-rating-marker { background-color: var(--user-rating-color); }

/* Ensure wrapper for the disabled slider has positioning context */
.slider-wrapper {
    position: relative;
    margin: 0.35rem 0 1.1rem 0;
    padding-top: 0.4rem; /* space for markers overlap */
}
.slider-wrapper input[type=range] {
    width: 100%;
    pointer-events: none; /* avoid confusion since disabled */
}

/* Legend for markers */
.rating-legend {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    margin: 0.25rem 0 0.75rem 0;
    flex-wrap: wrap;
    opacity: 0.9;
}
.rating-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.rating-legend .swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.swatch-global { background: var(--global-avg-color); }
.swatch-user { background: var(--user-rating-color); }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.notes-display span {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    margin: 0.2rem;
    background-color: #eee;
    border-radius: 4px;
}
.notes-display span.user-selected-note {
    background-color: var(--user-rating-color);
    color: white;
    font-weight: bold;
}


.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}
.modal.show { display: flex; }
.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
}
.close-btn {
    position: absolute;
    top: 10px; right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
}
.terms-content {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin: 1rem 0;
}
.notes-container div {
    display: inline-block;
    margin-right: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { background-color: #ccc; cursor: not-allowed; }
.btn-secondary { background-color: #6c757d; }
.btn-danger { background-color: #dc3545; }

input[type="email"], input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    margin: 0.5rem 0 1rem 0;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    box-sizing: border-box;
}

.cookie-banner {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
    transition: bottom 0.5s;
    z-index: 2000;
}
.cookie-banner.show { bottom: 0; }

.admin-panel {
    background-color: #fff3e0;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid var(--secondary-color);
}
.admin-panel.hidden { display: none; }
#add-item-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }

/* Admin manage existing */
.admin-existing-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}
.admin-existing-tools select {
    min-width: 260px;
    padding: 0.5rem;
}
.admin-manage-buttons { display: flex; gap: 0.5rem; }

/* Rating modal inline help */
.rating-field { margin-bottom: 1rem; }
.rating-field label { display: flex; justify-content: space-between; font-weight: 600; }
.slider-help-inline { display: block; font-size: 0.75rem; opacity: 0.85; margin: 0.1rem 0 0.35rem; }

.hidden { display: none !important; }

.static-page {
    max-width: 900px;
    margin: 0 auto;
}
.rankings-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-top: 2rem;
}
.ranking-category h2, .ranking-category h3 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ranking-list {
    list-style: none;
    padding-left: 0;
}
.ranking-list li {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ranking-list li .item-name {
    font-weight: bold;
}
.ranking-list li .item-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--secondary-color);
}

@media (min-width: 768px) {
    .rankings-container {
        grid-template-columns: repeat(3, 1fr);
    }
}