:root {
    --navy: #183153;
    --navy-light: #2b5278;
    --gold: #d4a017;
    --gold-light: #f4df9a;
    --ink: #263442;
    --muted: #667381;
    --line: #d7dee6;
    --paper: #ffffff;
    --background: #f4f7fa;
    --focus: #2674c5;
    --shadow: 0 12px 30px rgba(24, 49, 83, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-width: 280px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--background);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button,
a,
input,
select {
    outline-offset: 3px;
}

:focus-visible {
    outline: 3px solid var(--focus);
}

.site-header {
    color: #fff;
    background: var(--navy);
    border-bottom: 5px solid var(--gold);
}

.header-inner {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 1.15rem clamp(1rem, 3vw, 2.5rem) 1.35rem;
}

.home-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    color: var(--gold-light);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.home-link:hover {
    color: #fff;
    text-decoration: underline;
}

.eyebrow {
    margin: 0 0 0.15rem;
    color: #cbd7e5;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(1.55rem, 4vw, 2.45rem);
    line-height: 1.15;
}

.app-shell {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: clamp(1rem, 2vw, 2rem) clamp(0.75rem, 3vw, 2.5rem) 2.5rem;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(15rem, 2fr) minmax(12rem, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(24, 49, 83, 0.06);
}

.field {
    display: grid;
    gap: 0.35rem;
}

.field label {
    color: var(--navy);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.field input,
.field select {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 0.75rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid #aebac6;
    border-radius: 6px;
}

.field input:hover,
.field select:hover {
    border-color: var(--navy-light);
}

.viewer {
    overflow: hidden;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.image-stage {
    display: grid;
    min-height: min(62vh, 760px);
    max-height: 72vh;
    overflow: auto;
    place-items: center;
    padding: clamp(0.5rem, 1.5vw, 1.25rem);
    background-color: #e9eef3;
    background-image:
        linear-gradient(45deg, rgba(24, 49, 83, 0.025) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(24, 49, 83, 0.025) 25%, transparent 25%);
    background-size: 24px 24px;
}

.infographic {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(72vh - 2.5rem);
    object-fit: contain;
    box-shadow: 0 4px 18px rgba(23, 36, 50, 0.16);
}

.image-error {
    max-width: 32rem;
    padding: 2rem;
    color: var(--muted);
    text-align: center;
}

.details {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem 2rem;
    align-items: center;
    padding: 1.15rem clamp(1rem, 2vw, 1.5rem);
    border-top: 1px solid var(--line);
}

.title {
    margin: 0;
    color: var(--navy);
    font-size: clamp(1.15rem, 2.5vw, 1.55rem);
    line-height: 1.25;
}

.category {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.counter {
    margin: 0;
    color: var(--navy);
    font-weight: 700;
    white-space: nowrap;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0 1rem 1.15rem;
}

.button {
    min-height: 2.7rem;
    padding: 0.55rem 1rem;
    color: var(--navy);
    background: #fff;
    border: 1px solid var(--navy);
    border-radius: 6px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    color: #fff;
    background: var(--navy-light);
}

.button-primary {
    color: #fff;
    background: var(--navy);
}

.button-accent {
    color: #2e260d;
    background: var(--gold-light);
    border-color: var(--gold);
}

.button[hidden],
.empty-state[hidden] {
    display: none;
}

.empty-state,
.error-state,
.loading-state {
    display: grid;
    min-height: 18rem;
    padding: 2rem;
    place-content: center;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-align: center;
    box-shadow: var(--shadow);
}

.error-state h2 {
    margin: 0 0 0.5rem;
    color: var(--navy);
}

.error-state p,
.loading-state p {
    margin: 0;
}

.spinner {
    width: 2rem;
    height: 2rem;
    margin: 0 auto 0.85rem;
    border: 3px solid var(--line);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.noscript-message {
    margin: 2rem;
    padding: 1rem;
    color: #7a261f;
    background: #fff1f0;
    border-left: 5px solid #b43b32;
}

.image-stage:fullscreen {
    max-height: none;
    padding: 1rem;
    background: #111820;
}

.image-stage:fullscreen .infographic {
    max-width: 100%;
    max-height: calc(100vh - 2rem);
}

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

@media (max-width: 700px) {
    .toolbar {
        grid-template-columns: 1fr;
    }

    .image-stage {
        min-height: 48vh;
        max-height: 65vh;
    }

    .infographic {
        max-height: calc(65vh - 1rem);
    }

    .details {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

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

    .button {
        padding-inline: 0.65rem;
    }
}

@media (max-width: 390px) {
    .controls {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
    }
}
