:root {
    color-scheme: dark;
    --paper: #0c0c0b;
    --surface: #171513;
    --ink: #eee7dc;
    --muted: #b0a696;
    --line: #38342c;
    --accent: #d6b47f;
    font-family: system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-underline-offset: .22em; }
button { font: inherit; }
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.container { width: min(100% - 48px, 1184px); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: #090909; }
.header-inner { min-height: 62px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.brand { width: fit-content; color: var(--muted); font-size: 14px; text-decoration: none; }
.brand:hover { text-decoration: underline; }

main { flex: 1; }
h1 {
    margin: 0;
    font: 400 clamp(21px, 3vw, 30px)/1.12 Georgia, serif;
}
.intro { margin: 20px 0 0; font-size: 17px; line-height: 1.5; color: var(--muted); }
.gallery { padding-block: 22px 64px; }
.gallery .intro { margin-top: 0; font-size: 14px; text-align: center; }
.works {
    padding: 0;
    margin: 22px 0 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 36px 24px;
}
.work { min-width: 0; }
.art {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    padding: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
}
.art:hover { border-color: var(--accent); }
.art img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.caption { padding-top: 13px; overflow-wrap: anywhere; }
.caption h2 { margin: 0; font-size: 17px; line-height: 1.35; }
.caption p { margin: 4px 0 0; color: var(--muted); font: 17px/1.45 Georgia, serif; }
.finalist {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--accent);
    font-size: 13px;
    letter-spacing: .04em;
    text-decoration: none;
}
.finalist:hover { background: var(--accent); color: var(--paper); }
.others { margin-top: 10px; }   /* 01.12 Андрей: крупная работа → две мелкие → подпись */
.others ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.art-small { padding: 8px; }

.error { color: #ffaaa0; margin: 20px 0 0; line-height: 1.5; }
.site-footer { border-top: 1px solid var(--line); padding-block: 24px; color: var(--muted); font-size: 14px; }

body.viewer-open { overflow: hidden; }
.viewer {
    position: fixed;
    inset: 0;
    margin: 0;
    border: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    background: var(--paper);
    color: var(--ink);
}
.viewer::backdrop { background: var(--paper); }
.viewer-inner {
    display: flex;
    flex-direction: column;
    width: min(100%, 1520px);
    height: 100%;
    margin: auto;
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.viewer-toolbar { display: flex; justify-content: flex-end; }
.viewer-close, .viewer-arrow, .viewer-retry {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}
.viewer-close:hover, .viewer-arrow:hover, .viewer-retry:hover { border-color: var(--accent); color: var(--accent); }
.viewer-close, .viewer-arrow {
    width: 44px;
    height: 44px;
    padding: 0;
    font: 32px/1 Georgia, serif;
    display: grid;
    place-items: center;
    flex: none;
}
.viewer-figure { display: flex; flex: 1; flex-direction: column; gap: 12px; min-height: 0; margin: 0; }
.viewer-frame { display: grid; flex: 1; min-height: 0; grid-template-columns: auto minmax(0, 1fr) auto; gap: clamp(8px, 2vw, 24px); align-items: center; }
.viewer-stage { position: relative; height: 100%; min-height: 0; touch-action: pan-y; }
.viewer-layer { position: absolute; inset: 0; display: grid; place-items: center; }
.viewer-layer img { display: block; width: 100%; height: 100%; min-height: 0; min-width: 0; object-fit: contain; user-select: none; }
.viewer-caption { text-align: center; line-height: 1.4; overflow-wrap: anywhere; min-height: 45px; }
.viewer-name, .viewer-title { display: block; }
.viewer-title { color: var(--muted); font-family: Georgia, serif; }
.viewer-spinner, .viewer-retry { position: absolute; inset: 50% auto auto 50%; }
.viewer-spinner {
    margin: -17px 0 0 -17px;
    width: 34px;
    height: 34px;
    border: 3px solid #171513;
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 3px #0c0c0bba;
    animation: viewer-spin .7s linear infinite;
}
.viewer-retry { transform: translate(-50%, -50%); padding: 10px 14px; width: max-content; max-width: 100%; }
@keyframes viewer-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .viewer-spinner { animation: none; } }

@media (max-width: 850px) {
    .works { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
    .container { width: calc(100% - 36px); }
    .header-inner { grid-template-columns: 1fr auto; gap: 3px 12px; padding-block: 9px; }
    .header-inner h1 { grid-row: 2; }
    .brand { font-size: 12px; }
    .works { grid-template-columns: minmax(0, 1fr); gap: 27px; }
    .art { padding: 12px; }
    .viewer-inner { padding-inline: 8px; }
    .viewer-frame { position: relative; grid-template-columns: minmax(0, 1fr); }
    .viewer-arrow { position: absolute; z-index: 1; top: 50%; transform: translateY(-50%); background: #171513de; }
    .viewer-prev { left: 0; }
    .viewer-next { right: 0; }
}

/* 01.12 Андрей: крупная кнопка «Смотреть в 3D-галерее» над лонг-листом */
.to-3d { margin: 6px 0 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.to-3d-btn {
    display: inline-block;
    padding: 18px 40px;
    border-radius: 4px;
    background: var(--accent);
    color: #14110c;
    font: 600 clamp(18px, 2.4vw, 22px)/1.2 system-ui, sans-serif;
    letter-spacing: .02em;
    text-decoration: none;
}
.to-3d-btn:hover { background: #e6c896; }
.to-3d span { color: var(--muted); font-size: 14px; }
@media (max-width: 520px) { .to-3d-btn { width: 100%; padding: 16px 20px; } }
