:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --line: #d4dde7;
    --line-soft: #e7edf4;
    --accent: #1d4ed8;
    --accent-soft: #e8f0ff;
    --shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
    --shadow-hover: 0 14px 30px rgba(15, 23, 42, 0.10);
    --radius-xl: 20px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --container: min(1720px, calc(100vw - 40px));
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.is-locked {
    overflow: hidden;
}

img {
    display: block;
    width: 100%;
    max-width: 100%;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

.page-shell {
    min-height: 100vh;
    padding: 18px 0 36px;
}

.container {
    width: var(--container);
    margin: 0 auto;
}

.toolbar-card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 16px;
}

.toolbar-grid {
    display: grid;
    gap: 12px;
    align-items: end;
}

.toolbar-grid-home {
    grid-template-columns: minmax(0, 1fr) 260px auto;
}

.toolbar-grid-gallery {
    grid-template-columns: minmax(0, 1fr) 220px 220px auto;
}

.control-group {
    display: grid;
    gap: 8px;
}

.control-label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.search-shell,
.select-shell {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 50px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-shell:focus-within,
.select-shell:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.search-shell svg {
    width: 18px;
    height: 18px;
    margin-left: 16px;
    flex: 0 0 18px;
    fill: #94a3b8;
}

.search-shell input {
    width: 100%;
    border: 0;
    outline: none;
    padding: 0 14px 0 12px;
    color: var(--text);
    background: transparent;
}

.search-shell input::placeholder {
    color: #94a3b8;
}

.select-shell::after {
    content: "▾";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #64748b;
    font-size: 0.95rem;
}

.select-shell select {
    width: 100%;
    min-height: 50px;
    border: 0;
    outline: none;
    padding: 0 42px 0 16px;
    background: transparent;
    color: var(--text);
    appearance: none;
}

.results-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    color: #475467;
    white-space: nowrap;
}

.results-pill strong {
    color: var(--text);
    font-weight: 700;
}

.toolbar-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.back-link {
    color: var(--accent);
    font-weight: 700;
}

.toolbar-note {
    color: var(--muted);
    font-size: 0.94rem;
    text-align: right;
}

.page-heading {
    padding: 22px 2px 10px;
}

.eyebrow {
    margin: 0 0 8px;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 2.5rem);
    line-height: 1.08;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.page-copy {
    margin: 10px 0 0;
    max-width: 860px;
    color: var(--muted);
}

.field-grid,
.gallery-grid {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.field-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.gallery-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.field-link,
.gallery-card-button {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    contain: layout style paint;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.field-link:hover,
.field-link:focus-visible,
.gallery-card-button:hover,
.gallery-card-button:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: #c7d3e0;
}

.field-link:focus-visible,
.gallery-card-button:focus-visible {
    outline: 3px solid rgba(29, 78, 216, 0.15);
    outline-offset: 2px;
}

.field-link {
    padding: 16px;
}

.field-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}

.field-content {
    padding-top: 28px;
}

.field-content h2 {
    margin: 0;
    font-size: 1.28rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.field-content p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.96rem;
}

.field-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 22px;
    color: var(--muted);
    font-size: 0.94rem;
}

.field-action {
    color: var(--accent);
    font-weight: 700;
}

.gallery-card {
    min-width: 0;
    content-visibility: auto;
    contain: layout style paint;
    contain-intrinsic-size: 360px 420px;
}

.field-card {
    content-visibility: auto;
    contain: layout style paint;
    contain-intrinsic-size: 260px 220px;
}

.gallery-card-button {
    padding: 0;
    text-align: left;
    overflow: hidden;
}

.gallery-media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #dbe5ef;
    overflow: hidden;
}

.gallery-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    min-height: 126px;
}

.gallery-content h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
    font-weight: 700;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gallery-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef3f8;
    color: #475467;
    font-size: 0.78rem;
    font-weight: 700;
}

.gallery-chip-soft {
    background: #f5f7fb;
}

.gallery-footer-row {
    margin-top: auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    min-height: 20px;
}

.gallery-author {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.25;
    text-align: right;
}

.empty-state {
    margin-top: 18px;
    padding: 32px 20px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.empty-state-inline {
    grid-column: 1 / -1;
}

.empty-state h2 {
    margin: 0;
    font-size: 1.35rem;
}

.empty-state p {
    margin: 10px auto 0;
    max-width: 560px;
    color: var(--muted);
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
}

.lightbox-dialog {
    position: relative;
    z-index: 1;
    width: min(1120px, 100%);
    max-height: calc(100vh - 48px);
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 26px 80px rgba(15, 23, 42, 0.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.lightbox-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    font-size: 1.6rem;
    line-height: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    font-size: 1.5rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-nav:hover {
    background: rgba(15, 23, 42, 0.86);
}

.lightbox-nav:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.lightbox-nav-prev {
    left: 22px;
}

.lightbox-nav-next {
    right: 22px;
}

.lightbox-media {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #edf2f7;
    min-height: 0;
    flex: 1 1 auto;
}

.lightbox-media img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: 16px;
}

.lightbox-body {
    flex: 0 0 auto;
    padding: 18px 18px 20px;
    border-top: 1px solid var(--line-soft);
}

.lightbox-tag {
    margin: 0 0 8px;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lightbox-body h2 {
    margin: 0;
    font-size: 1.45rem;
    line-height: 1.25;
}

.lightbox-info-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-top: 12px;
}

.lightbox-info {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef3f8;
    color: #475467;
    font-size: 0.86rem;
    font-weight: 700;
}

.lightbox-author {
    margin-left: auto;
    background: transparent;
    padding-right: 0;
    color: var(--muted);
}

@media (max-width: 1380px) {
    .gallery-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1180px) {
    .toolbar-grid-home,
    .toolbar-grid-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .results-pill {
        justify-content: flex-start;
    }

    .toolbar-bottom {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-note {
        text-align: left;
    }

    .gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    :root {
        --container: min(100vw - 24px, 100%);
    }

    .page-shell {
        padding-top: 12px;
    }

    .toolbar-grid-home,
    .toolbar-grid-gallery {
        grid-template-columns: 1fr;
    }

    .field-grid,
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lightbox {
        padding: 12px;
    }

    .lightbox-dialog {
        max-height: calc(100vh - 24px);
    }

    .lightbox-media img {
        max-height: calc(100vh - 250px);
    }

    .lightbox-nav {
        width: 42px;
        height: 42px;
    }

    .lightbox-nav-prev {
        left: 14px;
    }

    .lightbox-nav-next {
        right: 14px;
    }
}

@media (max-width: 560px) {
    .field-grid,
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .field-footer,
    .lightbox-info-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .lightbox-author {
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


.lightbox-close,
.lightbox-nav {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

@media (max-width: 760px) {
    .site-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .site-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
