:root {
    --bg: #f4f4f0;
    --surface: #ffffff;
    --surface-muted: #ecece7;
    --line: #d8d8d1;
    --ink: #171714;
    --muted: #73736c;
    --accent: #c9972b;
    --danger: #a5362c;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(0,0,0,.025) 1px, transparent 1px),
        linear-gradient(rgba(0,0,0,.025) 1px, transparent 1px),
        var(--bg);
    background-size: 40px 40px;
}

button, input, select { font: inherit; }

.site-header {
    min-height: 78px;
    padding: 14px clamp(18px, 4vw, 58px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(255,255,255,.97);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
}

.identity {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 14px;
}

.identity strong,
.identity small { display: block; }

.identity strong { font-size: .96rem; }

.identity small {
    color: var(--muted);
    margin-top: 3px;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.brand-mark {
    font-family: Georgia, serif;
    color: var(--accent);
    font-size: 4.2rem;
    line-height: .9;
    letter-spacing: -.07em;
}

.brand-mark-small {
    font-size: 2.6rem;
    min-width: 72px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.button {
    border: 1px solid transparent;
    border-radius: 0;
    min-height: 44px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: var(--surface);
    text-decoration: none;
    cursor: pointer;
    font-weight: 650;
}

.button-primary {
    color: white;
    background: var(--ink);
    border-color: var(--ink);
}

.button-secondary { border-color: var(--line); }

.button-quiet {
    color: var(--muted);
    background: transparent;
}

.page-shell {
    width: min(1580px, calc(100% - 36px));
    margin: 0 auto;
    padding: 30px 0 58px;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 620px) 190px;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.search-field {
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.search-field svg {
    width: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.search-field input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
}

.select-control {
    min-height: 50px;
    padding: 0 14px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.status-panel {
    min-height: 180px;
    border: 1px dashed var(--line);
    background: rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
}

.status-panel[hidden] { display: none; }

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.media-card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 5px 5px 0 var(--surface-muted);
}

.media-stage {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #e8e8e3;
    border-bottom: 1px solid var(--line);
}

.media-stage img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.media-stage-placeholder {
    height: 100%;
    display: grid;
    place-items: center;
    padding: 20px;
    text-align: center;
    color: var(--muted);
}

.media-arrow,
.play-button {
    position: absolute;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    color: var(--ink);
    cursor: pointer;
}

.media-arrow {
    top: 50%;
    width: 42px;
    height: 42px;
    transform: translateY(-50%);
    font-size: 1.65rem;
}

.media-arrow.prev { left: 10px; }
.media-arrow.next { right: 10px; }

.media-counter {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 7px 9px;
    background: rgba(255,255,255,.95);
    border: 1px solid var(--line);
    font-size: .76rem;
    font-weight: 750;
}

.media-type {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 7px 9px;
    background: var(--ink);
    color: white;
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.play-button {
    width: 62px;
    height: 62px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
}

.media-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
}

.media-dot {
    width: 7px;
    height: 7px;
    background: rgba(255,255,255,.78);
    border: 1px solid rgba(0,0,0,.18);
}

.media-dot.active {
    background: var(--accent);
    border-color: var(--accent);
}

.card-body {
    min-height: 86px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.card-meta {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: .78rem;
}

.open-button {
    border: 0;
    border-bottom: 2px solid var(--accent);
    background: transparent;
    padding: 3px 0;
    font-weight: 700;
    cursor: pointer;
}

.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 34px;
}

.page-button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
}

.page-button.active {
    color: white;
    border-color: var(--ink);
    background: var(--ink);
}

.empty-state {
    grid-column: 1 / -1;
    min-height: 220px;
    display: grid;
    place-items: center;
    text-align: center;
    border: 1px dashed var(--line);
    background: var(--surface);
    color: var(--muted);
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(244,244,240,.98);
    display: grid;
    grid-template-columns: 72px 1fr 72px;
    grid-template-rows: 1fr auto;
    align-items: center;
}

.lightbox[hidden] { display: none; }

.lightbox-stage {
    width: min(1100px, 100%);
    height: min(76vh, 760px);
    margin: auto;
    display: grid;
    place-items: center;
    background: white;
    border: 1px solid var(--line);
}

.lightbox-stage img,
.lightbox-stage iframe {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    border: 0;
}

.lightbox-close,
.lightbox-arrow {
    border: 1px solid var(--line);
    background: white;
    cursor: pointer;
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 48px;
    height: 48px;
    z-index: 2;
    font-size: 1.8rem;
}

.lightbox-arrow {
    width: 52px;
    height: 72px;
    margin: auto;
    font-size: 2.2rem;
}

.lightbox-caption {
    grid-column: 1 / -1;
    min-height: 68px;
    padding: 18px 80px;
    text-align: center;
    border-top: 1px solid var(--line);
    background: white;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell { width: min(460px, 100%); }

.login-panel {
    padding: clamp(28px, 7vw, 52px);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 10px 10px 0 var(--surface-muted);
}

.brand-kicker {
    margin: 10px 0 34px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .18em;
    font-size: .72rem;
}

.login-panel h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 3.4rem);
    line-height: .95;
    letter-spacing: -.05em;
}

.login-copy { color: var(--muted); }

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 30px;
}

.login-form label {
    font-size: .78rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.login-form input {
    min-height: 50px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 0;
    outline: 0;
}

.alert {
    padding: 12px;
    color: var(--danger);
    border: 1px solid currentColor;
    margin-top: 20px;
}

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

@media (max-width: 820px) {
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar { grid-template-columns: 1fr; }
    .header-actions .button-secondary { display: none; }
}

@media (max-width: 560px) {
    .site-header { padding: 12px 15px; }
    .identity strong { font-size: .84rem; }
    .identity small { display: none; }
    .brand-mark-small { font-size: 2rem; min-width: 56px; }
    .button { padding: 0 12px; }
    .page-shell { width: min(100% - 24px, 1580px); padding-top: 18px; }
    .gallery-grid { grid-template-columns: 1fr; }
    .lightbox { grid-template-columns: 50px 1fr 50px; }
    .lightbox-stage { height: 70vh; }
    .lightbox-caption { padding: 14px 54px; }
}
