:root {
    --bg: #faf8f3;
    --surface: #ffffff;
    --border: #e7e1d6;
    --text: #2f2f2f;
    --text-muted: #8a7d63;
    --accent: #6d7f58;
    --accent-hover: #5c6b49;
    --accent-secondary: #b67852;
    --accent-secondary-hover: #9c6242;
    --accent-soft: #eee3d3;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(120,90,60,0.09), 0 3px 10px rgba(120,90,60,0.07);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
    background-repeat: repeat;
    color: var(--text);
    line-height: 1.5;
}

.site-header {
    text-align: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.1rem 1rem 0.9rem;
    position: relative;
}

.menu-toggle {
    display: none;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--accent-secondary);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
}

@media (max-width: 859px) {
    .brand { padding-left: 2.2rem; }
}

.brand-logo {
    display: block;
    height: 61px;
    width: auto;
}

.brand-text { text-align: left; }

.site-header h1 {
    margin: 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title-main {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--accent-secondary);
    font-family: Georgia, "Times New Roman", serif;
}

.brand-title-sub {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--accent-secondary);
    font-family: Georgia, "Times New Roman", serif;
    opacity: 0.8;
}

.brand-tagline {
    margin: 0.25rem 0 0;
    font-size: 0.72rem;
    font-style: italic;
    color: var(--text-muted);
}

.admin-actions {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
}

.admin-link {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}
.admin-link:hover { text-decoration: underline; }

.sidebar-summary {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    background: var(--accent-soft);
    border-radius: 10px;
    padding: 0.85rem 0.9rem;
    margin-top: 0.75rem;
}

.sidebar-summary-icon { font-size: 1.4rem; line-height: 1; }

.sidebar-summary-title {
    margin: 0 0 0.15rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-secondary);
    font-family: Georgia, "Times New Roman", serif;
}

.sidebar-summary-count {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-summary-line {
    margin: 0.1rem 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
}

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

.layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 860px) {
    .layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .sidebar {
        width: 230px;
        flex-shrink: 0;
        position: sticky;
        top: 1rem;
    }
    .results { flex: 1; min-width: 0; }
}

.sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    box-shadow: var(--shadow);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.6rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-home {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-secondary);
    text-decoration: none;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 19, 16, 0.45);
    z-index: 149;
}
.sidebar-backdrop[hidden] { display: none; }

@media (max-width: 859px) {
    .menu-toggle { display: block; }

    .sidebar-close { display: block; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: 82%;
        max-width: 320px;
        z-index: 150;
        border-radius: 0;
        border: none;
        box-shadow: 0 0 24px rgba(0,0,0,0.25);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: 2.5rem;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }
}

.filter-section {
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0;
}
.filter-section:last-of-type { border-bottom: none; }

.filter-section-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin: 0 0 0.4rem;
}

ul.filter-more-list {
    margin: 0;
}
.filter-more-list[hidden] { display: none; }

.filter-more-toggle {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: var(--accent);
    cursor: pointer;
    padding: 0.3rem 0.4rem;
}
.filter-more-toggle:hover { text-decoration: underline; }

.filter-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.filter-list li { margin: 0.15rem 0; }

.filter-list a {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
}
.filter-list a:hover { background: var(--bg); }
.filter-list a.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
}

.filter-list .count {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.ui-icon {
    display: inline-block;
    vertical-align: -3px;
    flex-shrink: 0;
}

.sidebar-home .ui-icon { color: var(--accent-secondary); }
.filter-section-title .ui-icon { color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; }
.sidebar-summary-icon .ui-icon { color: var(--accent-secondary); width: 22px; height: 22px; vertical-align: -5px; }
.top-search-icon .ui-icon { color: var(--text-muted); width: 16px; height: 16px; vertical-align: -3px; }
.rh-icon .ui-icon { color: var(--accent-secondary); width: 15px; height: 15px; vertical-align: -2px; }
.filtri-btn .ui-icon { color: #fff; }

.top-search-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.top-search-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

.top-search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    box-shadow: var(--shadow);
}

.top-search-icon { color: var(--text-muted); font-size: 0.95rem; }

.top-search-form input {
    flex: 1;
    border: none;
    background: none;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
}

.quick-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: 420px;
    overflow-y: auto;
    z-index: 120;
}
.quick-search-results[hidden] { display: none; }

.quick-result {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.8rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.quick-result:last-of-type { border-bottom: none; }
.quick-result:hover { background: var(--bg); }

.quick-result img {
    width: 38px;
    height: 46px;
    object-fit: contain;
    background: #f2ede1;
    border-radius: 4px;
    flex-shrink: 0;
}

.quick-result-country {
    font-weight: 600;
    color: var(--accent-secondary);
    font-size: 0.88rem;
}

.quick-result-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.quick-search-more {
    display: block;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.78rem;
    color: var(--accent);
    text-decoration: none;
}
.quick-search-more:hover { text-decoration: underline; }

.quick-search-empty {
    padding: 0.9rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.filtri-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 1.1rem;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}
.filtri-btn:hover { background: var(--accent-hover); }

.results-hero {
    background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.results-hero-title {
    margin: 0 0 0.6rem;
    font-size: 1.4rem;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--accent-secondary);
}

.results-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.rh-icon { margin-right: 0.3rem; }

.filters-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 19, 16, 0.5);
    z-index: 210;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.filters-modal[hidden] { display: none; }

.filters-modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

.filters-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.filters-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent-secondary);
    font-family: Georgia, "Times New Roman", serif;
}

.modal-close-inline {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.search-panel-form { }

.search-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 0.75rem;
    box-shadow: var(--shadow);
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.field-wide { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 0.25rem; }

.field label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.field input {
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--bg);
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
}

.autocomplete-wrap {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 0.55rem 0.65rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item:active {
    background: var(--bg);
}

.search-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.btn-primary, .btn-secondary {
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.88rem;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.result-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.sort-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sort-form select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 0.85rem;
    color: var(--text);
}

.toolbar-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.view-toggle-btn {
    background: var(--surface);
    border: none;
    padding: 0.4rem 0.55rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--border); }
.view-toggle-btn:hover { background: var(--bg); }
.view-toggle-btn.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.stamp-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.stamp-grid.view-list .stamp-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.stamp-grid.view-list .stamp-card img {
    width: 90px;
    aspect-ratio: auto;
    flex-shrink: 0;
    padding: 0.5rem;
}

.stamp-grid.view-list .stamp-info {
    flex: 1;
    justify-content: center;
}

.stamp-grid.view-list .stamp-comment {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stamp-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
}

@media (min-width: 640px) {
    .stamp-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
    .stamp-grid { grid-template-columns: repeat(4, 1fr); }
}

.stamp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stamp-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(120,90,60,0.14);
}

.stamp-card img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    background: #f2ede1;
    display: block;
    cursor: pointer;
    padding: 0.5rem;
    box-sizing: border-box;
}

.stamp-card-clickable { cursor: pointer; }

.stamp-card { position: relative; }

.fav-star {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 5;
    background: rgba(255,255,255,0.85);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-secondary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

button.fav-star { cursor: pointer; }
span.fav-star { pointer-events: none; }

.modal-fav-star {
    position: static;
    display: inline-flex;
    width: 26px;
    height: 26px;
    font-size: 0.95rem;
    vertical-align: middle;
    margin-left: 0.3rem;
    box-shadow: none;
    background: none;
}

.sidebar-favorites {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.6rem;
    margin: 0.4rem 0 0.6rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid var(--border);
}
.sidebar-favorites:hover { background: var(--bg); }
.sidebar-favorites.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}
.sidebar-favorites .count {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.78rem;
}

html.no-scroll {
    overflow: hidden;
    height: 100%;
}

body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.stamp-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 19, 16, 0.92);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.stamp-modal[hidden] { display: none; }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    max-width: 780px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (min-width: 700px) {
    .modal-content {
        flex-direction: row;
        max-height: 85vh;
    }
}

.modal-image-wrap {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f2ede1;
    padding: 1.5rem;
    min-height: 220px;
}

.modal-image-wrap img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 6px;
}

@media (min-width: 700px) {
    .modal-image-wrap img { max-height: 75vh; }
}

.modal-info {
    flex: 1 1 50%;
    padding: 1.25rem 1.5rem;
}

#modalCountryLine {
    margin: 0 0 0.3rem;
    font-size: 1.3rem;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--accent-secondary);
}

.modal-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 1rem;
}

.modal-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem 1rem;
    margin: 0 0 1rem;
}

.modal-fields dt {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin: 0 0 0.15rem;
}

.modal-fields dd {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.modal-comment {
    border-top: 1px solid var(--border);
    padding-top: 0.8rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.modal-close, .modal-nav {
    position: fixed;
    background: rgba(30, 26, 20, 0.65);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 201;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
.modal-close:hover, .modal-nav:hover { background: rgba(30, 26, 20, 0.85); }
.modal-nav:disabled { opacity: 0.3; cursor: default; }

.modal-close { top: 1rem; right: 1rem; }
.modal-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.modal-next { right: 1rem; top: 50%; transform: translateY(-50%); }

.stamp-info {
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.82rem;
}

.stamp-country {
    font-weight: 700;
    color: var(--accent-secondary);
    font-size: 0.9rem;
    font-family: Georgia, "Times New Roman", serif;
}
.stamp-year { color: var(--text-muted); font-size: 0.78rem; }
.stamp-location { font-size: 0.78rem; color: var(--text-muted); }
.stamp-value { font-weight: 600; font-size: 0.8rem; margin-top: 0.1rem; color: var(--text); }

.stamp-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.1rem 0;
}

.keyword-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
    font-size: 0.72rem;
    white-space: nowrap;
}

.stamp-comment {
    margin: 0.3rem 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    margin: 1.5rem 0 0.5rem;
    flex-wrap: wrap;
}

.pagination a, .pagination .page-current {
    min-width: 2.2rem;
    text-align: center;
    padding: 0.4rem 0.6rem;
}

.pagination-ellipsis {
    color: var(--text-muted);
    padding: 0 0.3rem;
}
