:root {
    --ink: #171412;
    --soft-ink: #4c4741;
    --muted: #82786d;
    --paper: #fbfaf7;
    --warm: #f1ece3;
    --veil: rgba(255, 255, 255, .74);
    --line: rgba(23, 20, 18, .12);
    --line-strong: rgba(23, 20, 18, .22);
    --accent: #8f3f2a;
    --accent-dark: #632a1f;
    --charcoal: #12100f;
    --shadow: 0 24px 70px rgba(23, 20, 18, .12);
    --page-rail: min(1500px, calc(100% - clamp(32px, 8vw, 132px)));
}

* {
    box-sizing: border-box;
}

html {
    color: var(--ink);
    background:
        linear-gradient(120deg, rgba(143, 63, 42, .08), transparent 38%),
        radial-gradient(circle at 84% 16%, rgba(216, 200, 176, .55), transparent 28rem),
        var(--paper);
    font-family: Manrope, sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .28;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(251, 250, 247, .9);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    width: var(--page-rail);
    margin: 0 auto;
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    font-family: "Fraunces", serif;
    font-size: clamp(1.35rem, 1.7vw, 1.9rem);
    font-weight: 650;
    letter-spacing: 0;
    text-decoration: none;
}

nav {
    display: flex;
    gap: 18px;
    font-size: .9rem;
    font-weight: 750;
}

nav a {
    color: var(--soft-ink);
    text-decoration: none;
}

main {
    position: relative;
    animation: page-in .42s ease both;
}

.flash,
.notice {
    width: min(1120px, calc(100% - 36px));
    margin: 18px auto 0;
    padding: 13px 16px;
    border: 1px solid rgba(143, 63, 42, .28);
    background: rgba(255, 248, 239, .82);
    color: var(--accent-dark);
    box-shadow: 0 10px 36px rgba(23, 20, 18, .05);
}

.access-hero,
.client-gate,
.admin-login {
    min-height: calc(100svh - 75px);
    display: grid;
    align-items: end;
    padding: clamp(28px, 6vw, 82px);
}

.access-hero,
.client-gate {
    color: #fffaf4;
    background:
        linear-gradient(90deg, rgba(18, 16, 15, .82) 0%, rgba(18, 16, 15, .54) 42%, rgba(18, 16, 15, .12) 100%),
        linear-gradient(135deg, #171412 0%, #7f6b57 47%, #e7d8c2 100%);
}

.access-hero::after,
.client-gate::after {
    content: "";
    position: absolute;
    inset: 75px 0 0;
    pointer-events: none;
    opacity: .22;
    background:
        linear-gradient(115deg, transparent 0 44%, rgba(255, 255, 255, .22) 44% 45%, transparent 45% 100%),
        radial-gradient(circle at 76% 34%, rgba(255, 255, 255, .42), transparent 18rem);
}

.admin-login {
    align-items: center;
    background:
        radial-gradient(circle at 80% 20%, rgba(143, 63, 42, .13), transparent 24rem),
        linear-gradient(135deg, var(--paper), var(--warm));
}

.access-copy,
.client-gate > div,
.admin-login > div {
    position: relative;
    z-index: 1;
    max-width: 720px;
}

.kicker {
    margin: 0 0 13px;
    color: var(--accent);
    font-size: .72rem;
    font-weight: 750;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.access-hero .kicker,
.client-gate .kicker {
    color: #ebc6ac;
}

h1 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-size: clamp(2.65rem, 7vw, 7rem);
    font-weight: 650;
    line-height: .92;
    letter-spacing: 0;
}

p {
    max-width: 62ch;
    line-height: 1.65;
}

.access-copy p,
.client-gate p {
    color: rgba(255, 250, 244, .82);
    font-size: clamp(1rem, 1.4vw, 1.22rem);
}

.muted,
small {
    color: var(--muted);
}

code {
    padding: 2px 5px;
    background: rgba(23, 20, 18, .06);
    font-size: .9em;
}

.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 43px;
    padding: 10px 17px;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    background: rgba(255, 255, 255, .72);
    color: var(--ink);
    font: 750 .9rem Manrope, sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

.button:hover,
.photo-button:hover,
.favorite:hover {
    transform: translateY(-2px);
}

.button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fffaf4;
}

.button.primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.button.danger {
    border-color: rgba(143, 63, 42, .42);
    background: rgba(143, 63, 42, .1);
    color: var(--accent-dark);
}

.button.is-disabled,
.button:disabled,
button.button:disabled {
    pointer-events: auto;
    cursor: not-allowed;
    border-color: var(--line);
    background: rgba(23, 20, 18, .12);
    color: rgba(23, 20, 18, .42);
}

.workspace {
    width: var(--page-rail);
    margin: 0 auto;
    padding: clamp(34px, 5vw, 70px) 0;
}

.workspace.narrow {
    width: min(800px, calc(100% - 40px));
}

.workspace-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 34px;
}

.workspace h1,
.client-intro h1 {
    font-size: clamp(2rem, 3.6vw, 4.35rem);
}

.gallery-list {
    border-top: 1px solid var(--line);
}

.gallery-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 22px;
    min-height: 82px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    transition: padding-left .18s ease, background .18s ease;
}

.storage-panel {
    margin: 0 0 28px;
    padding: 20px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.storage-line {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 12px;
}

.storage-line strong {
    font-family: "Fraunces", serif;
    font-size: clamp(2rem, 3vw, 3rem);
    line-height: 1;
}

.storage-line span {
    color: var(--muted);
}

.storage-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: end;
    gap: 10px 16px;
    font-size: .86rem;
}

.storage-bar {
    height: 9px;
    overflow: hidden;
    background: rgba(23, 20, 18, .1);
}

.storage-bar span {
    display: block;
    height: 100%;
    min-width: 2px;
    max-width: 100%;
    background: var(--accent);
}

.gallery-row:hover {
    padding-left: 12px;
    background: rgba(255, 255, 255, .38);
}

.gallery-row span:first-child {
    display: grid;
    gap: 5px;
}

.gallery-row strong {
    font-family: "Fraunces", serif;
    font-size: 1.35rem;
}

.stack-form,
.gate-form,
.ops-grid form {
    display: grid;
    gap: 16px;
}

.settings-section {
    display: grid;
    gap: 16px;
    padding: 0 0 28px;
    border-bottom: 1px solid var(--line);
}

.settings-section h2,
.delivery-panel h2 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-size: clamp(1.45rem, 2vw, 2rem);
    line-height: 1;
}

label {
    display: grid;
    gap: 7px;
    color: var(--soft-ink);
    font-size: .88rem;
    font-weight: 750;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    background: rgba(255, 255, 255, .76);
    padding: 12px 13px;
    color: var(--ink);
    font: 500 1rem Manrope, sans-serif;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(143, 63, 42, .58);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(143, 63, 42, .1);
}

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

.check {
    align-content: end;
    grid-template-columns: auto 1fr;
    align-items: center;
}

.check input {
    width: auto;
}

.ops-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
    gap: 20px;
    margin-bottom: 28px;
}

.upload-panel,
.delivery-panel {
    display: grid;
    align-content: space-between;
    gap: 18px;
    min-height: 230px;
    padding: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .56);
    box-shadow: 0 16px 46px rgba(23, 20, 18, .06);
}

.reset-downloads {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 28px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.delete-library {
    border-top: 0;
    margin-top: -28px;
}

.reset-downloads strong {
    display: block;
    margin-bottom: 4px;
}

.reset-downloads small {
    display: block;
}

.reset-downloads.is-pending {
    opacity: .86;
}

.form-pending {
    position: relative;
    margin: 12px 0 0;
    padding-left: 22px;
    color: var(--accent-dark);
    font-size: .9rem;
    line-height: 1.45;
}

.form-pending::before {
    content: "";
    position: absolute;
    left: 0;
    top: .42em;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(143, 63, 42, .25);
    border-top-color: var(--accent-dark);
    border-radius: 999px;
    animation: pending-spin .72s linear infinite;
}

.file-drop {
    position: relative;
    display: grid;
    place-items: center;
    gap: 8px;
    min-height: 145px;
    padding: 24px;
    border: 1px dashed rgba(23, 20, 18, .3);
    background:
        linear-gradient(135deg, rgba(143, 63, 42, .08), transparent),
        rgba(251, 250, 247, .7);
    text-align: center;
    cursor: pointer;
}

.file-drop input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-drop span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--ink);
    font-size: .82rem;
}

.file-drop strong {
    font-family: "Fraunces", serif;
    font-size: clamp(1.45rem, 2.3vw, 2.1rem);
    line-height: 1;
    color: var(--ink);
}

.file-drop small {
    max-width: 36ch;
}

.file-drop em {
    color: var(--accent-dark);
    font-style: normal;
    font-size: .82rem;
}

.upload-progress {
    display: grid;
    gap: 9px;
    padding-top: 2px;
}

.upload-progress[hidden] {
    display: none;
}

.upload-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    font-size: .86rem;
}

.upload-progress-head strong {
    color: var(--ink);
}

.upload-progress-head span {
    color: var(--accent-dark);
    font-weight: 750;
}

.upload-progress-bar {
    height: 8px;
    overflow: hidden;
    border: 1px solid rgba(143, 63, 42, .18);
    background: rgba(23, 20, 18, .07);
}

.upload-progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), #c27a55);
    transition: width .22s ease;
}

.upload-progress p {
    margin: 0;
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.45;
}

.upload-progress.is-processing .upload-progress-bar span {
    position: relative;
    overflow: hidden;
}

.upload-progress.is-processing .upload-progress-bar span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .52), transparent);
    animation: upload-shimmer 1.15s ease-in-out infinite;
}

.upload-progress.is-error .upload-progress-head strong,
.upload-progress.is-error .upload-progress-head span,
.upload-progress.is-error p {
    color: #8d1f16;
}

.upload-progress.is-error .upload-progress-bar span {
    background: #8d1f16;
}

.metrics {
    grid-template-columns: repeat(4, 1fr);
    margin: 26px 0 32px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.metrics span {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.metrics strong {
    color: var(--ink);
    font-family: "Fraunces", serif;
    font-size: clamp(1.8rem, 3vw, 2.65rem);
    line-height: 1;
    letter-spacing: 0;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.photo-grid figure {
    position: relative;
    margin: 0;
    overflow: hidden;
    background: #e8ded2;
    box-shadow: 0 1px 0 var(--line);
}

.photo-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    height: 100%;
    object-fit: cover;
    transform: scale(1.001);
}

.admin-grid figcaption,
.client-photo figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    padding: 10px 11px;
    background: rgba(251, 250, 247, .92);
    color: var(--soft-ink);
    font-size: .84rem;
}

.admin-grid figcaption span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-grid figcaption form {
    margin: 0;
}

.text-danger {
    border: 0;
    background: transparent;
    color: var(--accent-dark);
    cursor: pointer;
    font: 750 .82rem Manrope, sans-serif;
    text-decoration: underline;
}

.client-intro {
    width: var(--page-rail);
    margin: 0 auto;
    padding: clamp(44px, 7vw, 104px) 0 42px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
    align-items: end;
    gap: clamp(24px, 5vw, 88px);
}

.client-intro p {
    color: var(--soft-ink);
}

.client-actions {
    display: grid;
    justify-items: start;
    gap: 10px;
    padding-bottom: 6px;
}

.selection-note {
    margin-top: 10px;
    color: var(--muted);
    font-size: .92rem;
}

.client-gallery .photo-grid {
    width: var(--page-rail);
    margin: 0 auto 80px;
    display: block;
    column-count: 4;
    column-gap: clamp(6px, 1vw, 12px);
}

.client-gallery .photo-grid.is-small {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 420px));
    justify-content: start;
    align-items: start;
    gap: clamp(10px, 1.4vw, 18px);
    column-count: auto;
}

.client-gallery .client-photo {
    break-inside: avoid;
    display: inline-block;
    width: 100%;
    margin: 0 0 clamp(6px, 1vw, 12px);
    background: transparent;
    box-shadow: none;
}

.client-gallery .photo-grid.is-small .client-photo {
    display: block;
    margin: 0;
}

.client-gallery .photo-button {
    line-height: 0;
}

.client-gallery .photo-button img {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    object-fit: contain;
    transform: none;
}

.client-gallery .client-photo figcaption {
    position: absolute;
    inset: auto 10px 10px 10px;
    min-height: 0;
    padding: 0;
    background: transparent;
}

.client-gallery .client-photo figcaption a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 10px;
    background: rgba(255, 250, 244, .88);
    color: var(--ink);
    font-size: .78rem;
    font-weight: 750;
    text-decoration: none;
    backdrop-filter: blur(8px);
}

.photo-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    transition: transform .22s ease, filter .22s ease;
}

.photo-button:hover {
    filter: saturate(1.04) contrast(1.02);
}

.favorite {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, .82);
    color: var(--muted);
    cursor: pointer;
    transition: transform .18s ease, color .18s ease, background .18s ease, border-color .18s ease;
}

.favorite.is-on {
    border-color: var(--accent);
    background: var(--accent);
    color: #fffaf4;
}

.lightbox {
    width: min(1160px, calc(100% - 24px));
    border: 0;
    padding: 0;
    background: var(--charcoal);
    box-shadow: var(--shadow);
}

.lightbox::backdrop {
    background: rgba(18, 16, 15, .82);
    backdrop-filter: blur(12px);
}

.lightbox img {
    display: block;
    width: 100%;
    max-height: 84vh;
    object-fit: contain;
}

.lightbox .close {
    position: absolute;
    right: 12px;
    top: 12px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 250, 244, .92);
    color: var(--ink);
    cursor: pointer;
    font-size: 1.5rem;
}

.lightbox-actions {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lightbox-actions .favorite {
    width: 43px;
    height: 43px;
    background: rgba(255, 250, 244, .92);
    backdrop-filter: blur(8px);
}

.empty {
    padding: 44px 0;
    color: var(--muted);
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes upload-shimmer {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

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

@media (max-width: 860px) {
    :root {
        --page-rail: min(100% - 32px, 1500px);
    }

    .workspace-head {
        display: grid;
        align-items: start;
    }

    .client-intro {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 18px;
        padding-top: 38px;
    }

    .field-grid,
    .ops-grid,
    .reset-downloads,
    .storage-line,
    .metrics,
    .gallery-row {
        grid-template-columns: 1fr;
    }

    .storage-line {
        display: grid;
        align-items: start;
    }

    .storage-meta {
        justify-content: start;
    }

    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .client-gallery .photo-grid {
        column-count: 3;
    }

    .client-gallery .photo-grid.is-small {
        grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    }
}

@media (max-width: 560px) {
    .topbar-inner {
        align-items: start;
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        min-height: 94px;
    }

    nav {
        gap: 12px;
        font-size: .84rem;
    }

    .access-hero,
    .client-gate,
    .admin-login {
        min-height: calc(100svh - 112px);
        padding: 26px 20px 46px;
    }

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

    .client-gallery .photo-grid {
        column-count: 2;
        column-gap: 8px;
    }

    .client-gallery .photo-grid.is-small {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .client-gallery .client-photo {
        margin-bottom: 8px;
    }

    .client-gallery .photo-grid.is-small .client-photo {
        margin-bottom: 0;
    }
}
