:root {
    color-scheme: dark;
    --ink: #f8f5ed;
    --muted: #b9bdc5;
    --panel: #15171c;
    --line: rgba(255, 255, 255, .16);
    --accent: #ffcf53;
    --accent-2: #4ecdc4;
    --danger: #ff6b6b;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 207, 83, .2), transparent 34rem),
        linear-gradient(135deg, #20242b 0%, #0b0d10 58%, #101715 100%);
    color: var(--ink);
}

button {
    font: inherit;
}

img {
    max-width: 100%;
}

.camera-shell {
    height: 100dvh;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: clamp(.65rem, 2dvh, 1.25rem) clamp(.8rem, 3vw, 2rem);
}

.camera-stage {
    width: min(100%, 31rem);
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(.55rem, 1.6dvh, 1rem);
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.eyebrow {
    margin: 0 0 .2rem;
    color: var(--accent-2);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(1.9rem, 5.4dvh, 3.1rem);
    line-height: .95;
    letter-spacing: 0;
}

.counter {
    min-width: 4.8rem;
    padding: .75rem .9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    text-align: center;
}

.counter span {
    display: inline-block;
    min-width: 1.4rem;
    font-size: 1.7rem;
    font-weight: 900;
}

.counter small {
    color: var(--muted);
    font-weight: 700;
}

.viewfinder {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    background: #050607;
    box-shadow: 0 1.25rem 3rem rgba(0, 0, 0, .45);
}

.viewfinder video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transform: none !important;
}

.glass {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, .06) 50%, transparent 50%) 0 0 / 100% 4px,
        radial-gradient(circle at 50% 48%, transparent 0 45%, rgba(0, 0, 0, .25) 76%);
    mix-blend-mode: screen;
    opacity: .35;
}

.camera-message {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 1rem;
    font-weight: 800;
    text-align: center;
    background: rgba(0, 0, 0, .35);
}

.controls {
    min-height: 1.6rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    padding: 0;
}

.status-line,
.remaining {
    min-width: 5.75rem;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 800;
}

.remaining {
    text-align: right;
}

.shutter {
    position: absolute;
    left: 50%;
    bottom: clamp(.9rem, 2.7dvh, 1.45rem);
    z-index: 3;
    transform: translateX(-50%);
    width: 5.25rem;
    height: 5.25rem;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, .72);
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, opacity .16s ease;
}

.shutter span {
    width: 3.85rem;
    height: 3.85rem;
    display: block;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: inset 0 -.3rem 0 rgba(0, 0, 0, .18);
}

.shutter:hover:not(:disabled) {
    transform: translateX(-50%) translateY(-2px);
    border-color: var(--accent);
}

.shutter:active:not(:disabled) {
    transform: translateX(-50%) scale(.96);
}

.shutter:disabled {
    opacity: .38;
    cursor: default;
}

.closed-card {
    width: min(100%, 30rem);
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(21, 23, 28, .88);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .35);
}

.closed-card p:last-child {
    margin-bottom: 0;
    color: var(--muted);
    font-weight: 650;
}

.admin-shell {
    min-height: 100dvh;
    padding: clamp(1rem, 3vw, 2rem);
}

.admin-header {
    width: min(100%, 74rem);
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}

.admin-header h1 {
    font-size: clamp(2.2rem, 5vw, 4.2rem);
}

.admin-refresh {
    min-width: 6.8rem;
    min-height: 2.6rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--accent);
    color: #17120a;
    font-weight: 900;
    cursor: pointer;
}

.admin-refresh:hover {
    filter: brightness(1.06);
}

.admin-empty {
    width: min(100%, 74rem);
    margin: 0 auto;
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    color: var(--muted);
    font-weight: 800;
}

.admin-grid {
    width: min(100%, 74rem);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: 1rem;
}

.photo-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(21, 23, 28, .9);
    box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .26);
}

.photo-card img {
    width: 100%;
    aspect-ratio: 3 / 4;
    display: block;
    object-fit: cover;
    background: #050607;
}

.photo-card-body {
    display: grid;
    gap: .9rem;
    padding: 1rem;
}

.photo-card h2 {
    margin: 0;
    font-size: .96rem;
    overflow-wrap: anywhere;
}

.photo-card p {
    margin: .3rem 0 0;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.photo-card dl {
    margin: 0;
    display: grid;
    gap: .5rem;
}

.photo-card dl div {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: .6rem;
}

.photo-card dt {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.photo-card dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: .88rem;
    font-weight: 700;
}

.photo-card details {
    border-top: 1px solid var(--line);
    padding-top: .8rem;
}

.photo-card summary {
    cursor: pointer;
    color: var(--accent-2);
    font-weight: 900;
}

.photo-card pre {
    max-height: 18rem;
    overflow: auto;
    margin: .8rem 0 0;
    padding: .85rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, .36);
    color: #e9edf2;
    font-size: .75rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 420px) {
    .camera-shell {
        place-items: stretch;
        padding: .65rem;
    }

    .top-bar {
        align-items: flex-start;
    }

    .counter {
        min-width: 4.2rem;
        padding: .65rem .7rem;
    }

    .status-line,
    .remaining {
        min-width: 4.7rem;
        font-size: .78rem;
    }

    .shutter {
        width: 4.75rem;
        height: 4.75rem;
    }

    .shutter span {
        width: 3.45rem;
        height: 3.45rem;
    }

    .admin-header {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-refresh {
        width: 100%;
    }

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

@media (orientation: landscape) and (max-height: 560px) {
    .camera-shell {
        padding: 0 15vw;
    }

    body.phone-bottom-left .camera-shell {
        padding-left: 0;
        padding-right: 30vw;
    }

    body.phone-bottom-right .camera-shell {
        padding-left: 30vw;
        padding-right: 0;
    }

    .camera-stage {
        width: 100%;
        height: 100dvh;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        gap: 0;
    }

    .camera-stage .top-bar,
    .camera-stage .controls {
        display: none;
    }

    .camera-stage h1 {
        font-size: clamp(1.45rem, 8dvh, 2.35rem);
    }

    .counter {
        min-width: 4.2rem;
        padding: .55rem .7rem;
    }

    .viewfinder {
        grid-column: 1;
        grid-row: 1;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .shutter {
        width: 4.65rem;
        height: 4.65rem;
        bottom: .8rem;
    }

    .shutter span {
        width: 3.35rem;
        height: 3.35rem;
    }

    body.phone-bottom-left .viewfinder .shutter,
    body.phone-bottom-right .viewfinder .shutter {
        top: 50%;
        bottom: auto;
    }

    body.phone-bottom-left .viewfinder .shutter {
        left: .55rem;
        right: auto;
        transform: translateY(-50%);
    }

    body.phone-bottom-right .viewfinder .shutter {
        left: auto;
        right: .55rem;
        transform: translateY(-50%);
    }

    body.phone-bottom-left .viewfinder .shutter:hover:not(:disabled),
    body.phone-bottom-right .viewfinder .shutter:hover:not(:disabled) {
        transform: translateY(-50%) scale(1.03);
    }

    body.phone-bottom-left .viewfinder .shutter:active:not(:disabled),
    body.phone-bottom-right .viewfinder .shutter:active:not(:disabled) {
        transform: translateY(-50%) scale(.96);
    }
}
