:root {
    color-scheme: dark;
    --bg: #0b0d10;
    --surface: #12151a;
    --surface-strong: #191d24;
    --text: #f7f3ea;
    --muted: #9ca3ad;
    --line: rgba(255, 255, 255, 0.11);
    --accent: #ff6b4a;
    --accent-strong: #ff8064;
    --accent-ink: #1c0905;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
    --header-bg: rgba(11, 13, 16, 0.82);
    --radius-sm: 0.75rem;
    --radius-md: 1.25rem;
    --radius-lg: 2rem;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f1ea;
    --surface: #fffdf8;
    --surface-strong: #ebe6db;
    --text: #141619;
    --muted: #686d75;
    --line: rgba(20, 22, 25, 0.13);
    --accent: #e94f2e;
    --accent-strong: #d84324;
    --accent-ink: #fff8f3;
    --shadow: 0 24px 70px rgba(46, 39, 31, 0.14);
    --header-bg: rgba(244, 241, 234, 0.85);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 20rem;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    transition: background-color 180ms ease, color 180ms ease;
}

button,
input,
select {
    font: inherit;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

button,
select {
    cursor: pointer;
}

a {
    color: inherit;
}

.skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 100;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 750;
    transform: translateY(-160%);
    transition: transform 150ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 4.75rem;
    padding: 0 4vw;
    border-bottom: 1px solid var(--line);
    background: var(--header-bg);
    backdrop-filter: blur(20px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 0.6rem;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 1rem;
    font-weight: 900;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.icon-button,
.settings-button {
    display: inline-flex;
    min-height: 2.75rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.icon-button:hover,
.settings-button:hover {
    border-color: color-mix(in srgb, var(--accent), transparent 35%);
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.icon-button {
    width: 2.75rem;
    padding: 0;
}

.settings-button {
    gap: 0.5rem;
    padding: 0 1rem;
    font-size: 0.875rem;
    font-weight: 700;
}

.icon-button svg,
.settings-button svg,
.search-form svg,
.load-more svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.moon-icon,
[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

.search-stage {
    position: relative;
    overflow: hidden;
    padding: clamp(4.5rem, 10vw, 9rem) max(5vw, calc((100vw - 78rem) / 2)) clamp(4rem, 8vw, 7rem);
    border-bottom: 1px solid var(--line);
}

.search-stage::before {
    position: absolute;
    top: -12rem;
    right: -10rem;
    width: 32rem;
    height: 32rem;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent), transparent 72%) 0%, transparent 68%);
    content: "";
    pointer-events: none;
}

.eyebrow,
.section-kicker {
    margin: 0 0 0.85rem;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 11ch;
    margin-bottom: 1.2rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(3.2rem, 8vw, 7.6rem);
    font-weight: 500;
    letter-spacing: -0.065em;
    line-height: 0.93;
}

.intro {
    max-width: 37rem;
    margin-bottom: 2rem;
    color: var(--muted);
    font-size: clamp(1rem, 1.6vw, 1.2rem);
}

.search-form {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    max-width: 48rem;
    padding: 0.4rem;
    border: 1px solid var(--line);
    border-radius: 1.15rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent), transparent 82%), var(--shadow);
}

.search-form > svg {
    width: 1.3rem;
    height: 1.3rem;
    margin-left: 1rem;
    color: var(--muted);
}

.search-form input {
    min-width: 0;
    height: 3.8rem;
    padding: 0 1rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
}

.search-form input::placeholder {
    color: color-mix(in srgb, var(--muted), transparent 20%);
}

.search-form button,
.primary-button {
    min-height: 3.2rem;
    padding: 0 1.5rem;
    border: 0;
    border-radius: 0.8rem;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800;
    transition: background-color 150ms ease, transform 150ms ease;
}

.search-form button:hover,
.primary-button:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    margin-top: 1.2rem;
    color: var(--muted);
    font-size: 0.875rem;
}

.suggestions > span {
    margin-right: 0.2rem;
    font-weight: 700;
}

.suggestions button {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.8125rem;
    transition: color 150ms ease, border-color 150ms ease;
}

.suggestions button:hover {
    border-color: var(--accent);
    color: var(--text);
}

.gallery-section {
    min-height: 45rem;
    padding: clamp(3rem, 6vw, 5.5rem) 4vw 6rem;
}

.results-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    max-width: 88rem;
    margin: 0 auto 2rem;
    gap: 2rem;
}

.results-toolbar h2 {
    margin-bottom: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 4vw, 3.4rem);
    font-weight: 500;
    letter-spacing: -0.045em;
    line-height: 1;
}

.filters {
    display: flex;
    gap: 0.75rem;
}

.filters label {
    display: grid;
    gap: 0.3rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.filters select {
    min-width: 8rem;
    height: 2.75rem;
    padding: 0 2rem 0 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
}

.status-panel {
    display: grid;
    max-width: 36rem;
    min-height: 24rem;
    margin: 4rem auto;
    place-items: center;
    align-content: center;
    text-align: center;
}

.status-panel h3 {
    margin: 1.4rem 0 0.4rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: -0.04em;
}

.status-panel p {
    max-width: 29rem;
    color: var(--muted);
}

.status-panel button {
    margin-top: 0.75rem;
}

.status-art {
    display: flex;
    height: 7.5rem;
    align-items: end;
    gap: 0.55rem;
}

.status-art span {
    display: block;
    width: 3.5rem;
    border-radius: 2rem 2rem 0.8rem 0.8rem;
    background: var(--surface-strong);
    transform: rotate(-7deg);
}

.status-art span:nth-child(1) { height: 62%; }
.status-art span:nth-child(2) { height: 100%; background: var(--accent); transform: translateY(-0.5rem) rotate(4deg); }
.status-art span:nth-child(3) { height: 78%; transform: rotate(8deg); }

.gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 88rem;
    margin: 0 auto;
    gap: 1rem;
}

.photo-card {
    position: relative;
    overflow: hidden;
    min-height: 22rem;
    border-radius: var(--radius-md);
    background: var(--surface-strong);
    isolation: isolate;
}

.photo-card:nth-child(6n + 1),
.photo-card:nth-child(6n + 5) {
    grid-row: span 2;
    min-height: 36rem;
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.photo-card:hover img,
.photo-card:focus-within img {
    transform: scale(1.035);
}

.photo-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(to top, rgba(3, 5, 8, 0.78), transparent 52%);
    color: white;
    opacity: 0;
    transition: opacity 180ms ease;
}

.photo-card:hover .photo-overlay,
.photo-card:focus-within .photo-overlay {
    opacity: 1;
}

.photographer {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.65rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
}

.photographer img {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
}

.photographer span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-actions {
    display: flex;
    gap: 0.45rem;
}

.photo-action {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(9, 11, 14, 0.48);
    color: white;
    text-decoration: none;
    backdrop-filter: blur(10px);
}

.photo-action:hover {
    background: white;
    color: #111318;
}

.photo-action svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.skeleton {
    min-height: 22rem;
    border-radius: var(--radius-md);
    background: linear-gradient(100deg, var(--surface) 20%, var(--surface-strong) 42%, var(--surface) 64%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
}

.skeleton:nth-child(1),
.skeleton:nth-child(5) {
    min-height: 36rem;
    grid-row: span 2;
}

@keyframes shimmer {
    to { background-position-x: -200%; }
}

.load-more-wrap {
    display: grid;
    place-items: center;
    margin-top: 2.5rem;
}

.load-more,
.secondary-button {
    display: inline-flex;
    min-height: 3rem;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0 1.2rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 750;
}

.load-more:hover,
.secondary-button:hover {
    border-color: var(--accent);
    background: var(--surface-strong);
}

.load-more[aria-busy="true"] svg {
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 2rem 4vw;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.875rem;
}

footer p {
    margin: 0;
}

footer a:not(.brand) {
    color: var(--text);
    font-weight: 700;
}

.footer-note {
    justify-self: end;
}

.settings-dialog {
    width: min(34rem, calc(100% - 2rem));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.dialog-card {
    position: relative;
    padding: clamp(1.5rem, 5vw, 2.5rem);
}

.dialog-card h2 {
    margin-bottom: 0.75rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2.3rem;
    font-weight: 500;
    letter-spacing: -0.04em;
}

.dialog-card > p:not(.section-kicker) {
    color: var(--muted);
}

.dialog-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
}

.key-field {
    display: grid;
    gap: 0.45rem;
    margin-top: 1.5rem;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 750;
}

.key-field input {
    width: 100%;
    height: 3.4rem;
    padding: 0 1rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    outline: none;
    background: var(--bg);
    color: var(--text);
}

.key-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 82%);
}

.dialog-help {
    margin-top: 0.65rem;
    font-size: 0.8125rem;
}

.dialog-help a {
    color: var(--text);
    font-weight: 700;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 1.5rem;
}

.primary-button {
    min-height: 3rem;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 50;
    max-width: min(24rem, calc(100% - 2rem));
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    font-weight: 650;
    opacity: 0;
    pointer-events: none;
    transform: translateY(0.8rem);
    transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.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;
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent), white 15%);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

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

    footer {
        grid-template-columns: 1fr auto;
    }

    footer > p:first-of-type {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding-inline: 1rem;
    }

    .settings-button span {
        display: none;
    }

    .settings-button {
        width: 2.75rem;
        padding: 0;
    }

    .search-stage {
        padding: 4.5rem 1rem 3.5rem;
    }

    h1 {
        font-size: clamp(3rem, 16vw, 4.8rem);
    }

    .search-form {
        grid-template-columns: auto 1fr;
        padding: 0.25rem;
    }

    .search-form button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .search-form input {
        height: 3.3rem;
        padding-left: 0.75rem;
    }

    .gallery-section {
        padding-inline: 1rem;
    }

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

    .filters {
        width: 100%;
    }

    .filters label {
        flex: 1;
    }

    .filters select {
        width: 100%;
        min-width: 0;
    }

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

    .photo-card,
    .photo-card:nth-child(6n + 1),
    .photo-card:nth-child(6n + 5),
    .skeleton,
    .skeleton:nth-child(1),
    .skeleton:nth-child(5) {
        min-height: 28rem;
        grid-row: auto;
    }

    .photo-overlay {
        opacity: 1;
    }

    footer {
        display: flex;
        align-items: flex-start;
        flex-direction: column;
        padding-inline: 1rem;
    }

    .footer-note {
        justify-self: auto;
    }

    .dialog-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
