:root {
    color-scheme: only light;
    --bg: #e9dece;
    --bg-soft: rgba(247, 240, 230, 0.9);
    --panel: rgba(252, 247, 239, 0.76);
    --line: rgba(114, 87, 63, 0.16);
    --ink: #402e20;
    --ink-soft: rgba(64, 46, 32, 0.72);
    --accent: #d39a6c;
    --accent-deep: #aa6f49;
    --danger: #d66b57;
    --shadow: rgba(69, 50, 35, 0.2);
    --safe-top: max(18px, env(safe-area-inset-top));
    --safe-bottom: max(22px, env(safe-area-inset-bottom));
    --control-lift: clamp(54px, 10vh, 92px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
}

body {
    font-family: "Avenir Next Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
    color: var(--ink);
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top, rgba(255, 245, 228, 0.78), transparent 24%),
        radial-gradient(circle at bottom right, rgba(211, 154, 108, 0.18), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent 20%, rgba(126, 95, 66, 0.14) 100%);
    mix-blend-mode: multiply;
}

.background-wash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, transparent 20%),
        radial-gradient(circle at center, transparent 52%, rgba(92, 69, 51, 0.16) 100%);
}

.app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.camera-stage {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
    background: linear-gradient(180deg, #efe6d8 0%, #d9c7b4 100%);
    --polaroid-frame-left: 7.5%;
    --polaroid-frame-right: 7.5%;
    --polaroid-frame-top: 4.5%;
    --polaroid-frame-bottom: 6.5%;
    --polaroid-photo-left: 14.3%;
    --polaroid-photo-right: 14.3%;
    --polaroid-photo-top: 9.4%;
    --polaroid-photo-bottom: 19.4%;
}

.preview-window,
.camera-mask,
.flash-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.preview-window {
    left: var(--polaroid-photo-left);
    right: var(--polaroid-photo-right);
    top: var(--polaroid-photo-top);
    bottom: var(--polaroid-photo-bottom);
    width: auto;
    height: auto;
    z-index: 1;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(255, 236, 203, 0.18), transparent 26%),
        linear-gradient(180deg, #3f3127 0%, #17110d 100%);
}

.preview-window::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, transparent 18%, transparent 74%, rgba(31, 20, 12, 0.18) 100%),
        radial-gradient(circle at 50% 12%, rgba(255, 252, 247, 0.08), transparent 36%);
    pointer-events: none;
}

.preview-window::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow:
        inset 0 0 0 1px rgba(199, 181, 163, 0.38),
        inset 0 14px 22px rgba(255, 255, 255, 0.05),
        inset 0 -22px 28px rgba(23, 15, 9, 0.2);
    pointer-events: none;
}

#camera-video,
#capture-canvas,
#frame-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#camera-video,
#capture-canvas {
    object-fit: cover;
    background: transparent;
}

#camera-video.mirrored,
#capture-canvas.mirrored {
    transform: scaleX(-1);
}

#camera-video.is-hidden {
    opacity: 0;
}

#capture-canvas {
    z-index: 2;
}

#frame-overlay {
    z-index: 3;
    object-fit: cover;
    pointer-events: none;
}

.camera-mask {
    z-index: 4;
    pointer-events: none;
}

.camera-mask::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(96, 72, 50, 0.16), transparent 16%, transparent 76%, rgba(90, 66, 44, 0.26)),
        radial-gradient(circle at center, transparent 54%, rgba(65, 48, 35, 0.14) 100%);
}

.camera-mask::after {
    content: "";
    position: absolute;
    left: var(--polaroid-frame-left);
    right: var(--polaroid-frame-right);
    top: var(--polaroid-frame-top);
    bottom: var(--polaroid-frame-bottom);
    border-radius: 2px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, transparent 22%, transparent 70%, rgba(183, 148, 117, 0.08) 100%),
        radial-gradient(circle at 50% 120%, rgba(149, 111, 79, 0.08), transparent 40%);
    box-shadow:
        0 22px 48px rgba(77, 57, 40, 0.18),
        inset 0 0 0 1px rgba(227, 218, 207, 0.58),
        inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.frame-paper {
    position: absolute;
    background:
        radial-gradient(circle at 22% 16%, rgba(255, 255, 255, 0.42), transparent 28%),
        linear-gradient(180deg, rgba(253, 250, 245, 0.98) 0%, rgba(246, 238, 228, 0.98) 100%);
    box-shadow:
        inset 0 0 0 1px rgba(231, 221, 210, 0.56),
        inset 0 12px 18px rgba(255, 255, 255, 0.18),
        inset 0 -16px 22px rgba(177, 138, 103, 0.08);
}

.frame-paper-top {
    left: var(--polaroid-frame-left);
    right: var(--polaroid-frame-right);
    top: var(--polaroid-frame-top);
    height: calc(var(--polaroid-photo-top) - var(--polaroid-frame-top));
}

.frame-paper-left {
    left: var(--polaroid-frame-left);
    top: var(--polaroid-photo-top);
    bottom: var(--polaroid-photo-bottom);
    width: calc(var(--polaroid-photo-left) - var(--polaroid-frame-left));
}

.frame-paper-right {
    right: var(--polaroid-frame-right);
    top: var(--polaroid-photo-top);
    bottom: var(--polaroid-photo-bottom);
    width: calc(var(--polaroid-photo-right) - var(--polaroid-frame-right));
}

.frame-paper-bottom {
    left: var(--polaroid-frame-left);
    right: var(--polaroid-frame-right);
    top: calc(100% - var(--polaroid-photo-bottom));
    bottom: var(--polaroid-frame-bottom);
    background:
        radial-gradient(circle at 16% 14%, rgba(255, 255, 255, 0.36), transparent 18%),
        linear-gradient(180deg, rgba(251, 248, 242, 0.99) 0%, rgba(242, 235, 226, 0.98) 100%);
    box-shadow:
        inset 0 0 0 1px rgba(231, 221, 210, 0.52),
        inset 0 22px 26px rgba(255, 255, 255, 0.12),
        inset 0 -18px 24px rgba(162, 122, 88, 0.1);
}

.flash-layer {
    z-index: 5;
    background: rgba(255, 245, 225, 0.9);
    opacity: 0;
}

.flash-layer.active {
    animation: flash-burst 280ms ease-out;
}

@keyframes flash-burst {
    0% {
        opacity: 0;
    }

    24% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.status-hud {
    position: absolute;
    top: calc(var(--safe-top) + 10px);
    left: 50%;
    z-index: 7;
    display: grid;
    justify-items: center;
    gap: 10px;
    width: min(100% - 32px, 420px);
    transform: translateX(-50%);
}

.status-chip {
    margin: 0;
    width: fit-content;
    max-width: 100%;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(251, 246, 238, 0.88);
    color: var(--ink);
    box-shadow: 0 12px 30px rgba(83, 62, 45, 0.12);
    backdrop-filter: blur(18px);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
}

.status-chip-stage {
    background: rgba(251, 234, 224, 0.94);
}

.status-chip-upload {
    background: rgba(245, 239, 231, 0.94);
}

.entry-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    padding: calc(var(--safe-top) + 32px) 20px calc(var(--safe-bottom) + 224px);
    pointer-events: none;
}

.entry-card {
    width: min(100%, 360px);
    padding: 22px 22px 20px;
    border: 1px solid rgba(151, 117, 87, 0.16);
    border-radius: 28px;
    background:
        radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.34), transparent 26%),
        linear-gradient(180deg, rgba(252, 247, 240, 0.93) 0%, rgba(244, 236, 226, 0.9) 100%);
    box-shadow:
        0 28px 60px rgba(79, 58, 41, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    pointer-events: auto;
}

.entry-kicker,
.entry-title,
.entry-copy,
.entry-hint {
    margin: 0;
}

.entry-kicker {
    color: rgba(103, 74, 48, 0.72);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.entry-title {
    margin-top: 10px;
    font-size: clamp(1.7rem, 5vw, 2.15rem);
    line-height: 1.02;
    letter-spacing: 0.01em;
}

.entry-copy {
    margin-top: 14px;
    color: rgba(64, 46, 32, 0.86);
    font-size: 0.98rem;
    line-height: 1.5;
}

.entry-field,
.entry-field-hint {
    margin: 0;
}

.entry-field {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.entry-field-label {
    color: rgba(85, 60, 39, 0.82);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.entry-name-input {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    border: 1px solid rgba(143, 108, 77, 0.2);
    border-radius: 16px;
    background: rgba(255, 252, 247, 0.9);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.entry-name-input::placeholder {
    color: rgba(101, 74, 48, 0.46);
}

.entry-name-input:focus {
    outline: 2px solid rgba(170, 111, 73, 0.28);
    outline-offset: 2px;
    border-color: rgba(170, 111, 73, 0.4);
}

.entry-field-hint {
    margin-top: 10px;
    color: rgba(109, 81, 55, 0.72);
    font-size: 0.78rem;
    line-height: 1.4;
}

.entry-hint {
    margin-top: 12px;
    color: rgba(109, 81, 55, 0.78);
    font-size: 0.84rem;
    line-height: 1.45;
}

.entry-action-button {
    appearance: none;
    margin-top: 16px;
    min-height: 54px;
    width: 100%;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(180deg, #4b3627 0%, #2f231a 100%);
    color: #fffaf3;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.04em;
    box-shadow:
        0 18px 32px rgba(61, 43, 29, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.entry-action-button:disabled {
    opacity: 0.55;
}

.zoom-control {
    position: absolute;
    left: 50%;
    bottom: calc(var(--safe-bottom) + var(--control-lift) + clamp(104px, 22vw, 132px));
    z-index: 7;
    width: min(84vw, 360px);
    height: 52px;
    transform: translateX(-50%);
    cursor: ew-resize;
    pointer-events: auto;
    touch-action: none;
    --zoom-ratio: 0;
}

.zoom-control::before,
.zoom-control::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    border-radius: 999px;
    transform: translateY(-50%);
    pointer-events: none;
}

.zoom-control::before {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.36) 50%, rgba(255, 255, 255, 0.1) 100%);
    box-shadow: 0 0 0 1px rgba(94, 70, 51, 0.08);
}

.zoom-control::after {
    right: auto;
    width: calc(var(--zoom-ratio) * 100%);
    min-width: 4px;
    background: linear-gradient(90deg, rgba(255, 249, 240, 0.38) 0%, rgba(255, 255, 255, 0.9) 100%);
    box-shadow: 0 0 14px rgba(255, 247, 232, 0.24);
}

.zoom-control.is-disabled {
    cursor: default;
    opacity: 0.5;
    pointer-events: none;
}

.zoom-control:focus-visible {
    outline: none;
}

.zoom-control:focus-visible::before {
    box-shadow: 0 0 0 1px rgba(94, 70, 51, 0.08), 0 0 0 6px rgba(255, 246, 235, 0.12);
}

.zoom-slider {
    appearance: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    background: transparent;
    pointer-events: none;
}

.zoom-slider:disabled {
    opacity: 0.45;
}

.zoom-slider::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
    border-radius: 999px;
    box-shadow: none;
}

.zoom-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    margin-top: -8px;
    border: 1px solid rgba(134, 103, 78, 0.24);
    border-radius: 50%;
    background: rgba(255, 250, 243, 0.84);
    box-shadow: 0 10px 24px rgba(65, 49, 36, 0.18);
}

.zoom-slider::-moz-range-track {
    height: 4px;
    border: none;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
}

.zoom-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(134, 103, 78, 0.24);
    border-radius: 50%;
    background: rgba(255, 250, 243, 0.84);
    box-shadow: 0 10px 24px rgba(65, 49, 36, 0.18);
}

.control-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 18px;
    padding: 18px max(18px, env(safe-area-inset-right)) calc(var(--safe-bottom) + var(--control-lift)) max(18px, env(safe-area-inset-left));
    background: linear-gradient(180deg, transparent 0%, rgba(242, 233, 221, 0.08) 22%, rgba(241, 232, 219, 0.38) 55%, rgba(235, 224, 210, 0.9) 100%);
}

.control-button,
.shutter-button,
.sheet-dismiss,
.review-thumb-button {
    appearance: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.control-button {
    position: relative;
    width: 82px;
    height: 82px;
    border-radius: 24px;
    align-self: center;
    background: var(--panel);
    border: 1px solid rgba(139, 108, 80, 0.18);
    box-shadow: 0 18px 36px var(--shadow);
    backdrop-filter: blur(20px);
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.control-button:hover,
.control-button:focus-visible,
.shutter-button:hover,
.shutter-button:focus-visible,
.sheet-dismiss:hover,
.sheet-dismiss:focus-visible,
.review-thumb-button:hover,
.review-thumb-button:focus-visible {
    transform: translateY(-1px);
}

.review-button {
    justify-self: start;
    overflow: hidden;
}

.review-thumb {
    position: absolute;
    inset: 0;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    filter: brightness(1.08) saturate(1.08);
}

.review-button::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 26px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.18));
}

.review-icon,
.control-icon {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 32px;
    height: 32px;
    transform: translate(-50%, -50%);
}

.review-icon {
    z-index: 1;
}

.mode-button {
    justify-self: end;
}

.mode-button[data-mode="retry"] {
    background: rgba(252, 232, 225, 0.94);
    border-color: rgba(214, 107, 87, 0.3);
}

.shutter-button {
    position: relative;
    width: min(34vw, 112px);
    height: min(34vw, 112px);
    min-width: 98px;
    min-height: 98px;
    border-radius: 50%;
    justify-self: center;
    background: radial-gradient(circle at 35% 35%, #fffdf8 0%, #f1e5d3 48%, #d8c1a8 100%);
    box-shadow:
        inset 0 -12px 22px rgba(126, 93, 63, 0.18),
        0 24px 44px rgba(88, 64, 42, 0.2);
    transition: transform 140ms ease, box-shadow 180ms ease;
}

.shutter-ring,
.shutter-core {
    position: absolute;
    inset: 50%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.shutter-ring {
    width: 72%;
    height: 72%;
    border: 12px solid rgba(255, 255, 255, 0.92);
    box-shadow:
        inset 0 0 0 1px rgba(123, 95, 66, 0.08),
        0 0 0 8px rgba(255, 255, 255, 0.18);
}

.shutter-core {
    width: 22%;
    height: 22%;
    background: rgba(216, 193, 168, 0.52);
}

.shutter-button:active {
    transform: translateY(2px) scale(0.985);
}

.review-sheet {
    position: fixed;
    inset: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: calc(var(--safe-top) + 8px) 0 calc(var(--safe-bottom) + 12px);
    background: rgba(234, 223, 209, 0.96);
    backdrop-filter: blur(20px);
}

.review-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    flex-shrink: 0;
}

.sheet-dismiss {
    justify-self: end;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 250, 244, 0.84);
    border: 1px solid rgba(141, 110, 84, 0.14);
}

.sheet-dismiss-icon {
    width: 22px;
    height: 22px;
}

.review-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.review-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid rgba(141, 110, 84, 0.16);
    background: rgba(255, 250, 244, 0.72);
    color: rgba(64, 46, 32, 0.86);
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.review-toggle input {
    margin: 0;
}

.review-device-time {
    margin: 0;
    color: rgba(86, 62, 42, 0.84);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: right;
}

.review-status {
    margin: 0;
    padding: 0 14px;
    color: rgba(93, 67, 45, 0.85);
    font-size: 0.82rem;
    line-height: 1.45;
    flex-shrink: 0;
}

.review-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 0 0 4px;
    align-content: start;
    -webkit-overflow-scrolling: touch;
}

.review-grid-item {
    appearance: none;
    border: none;
    margin: 0;
    padding: 0;
    background: rgba(225, 215, 200, 0.6);
    cursor: pointer;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    display: block;
    width: 100%;
}

.review-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 180ms ease;
}

.review-grid-item:hover img,
.review-grid-item:focus-visible img {
    opacity: 0.82;
}

.review-lightbox {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(30, 20, 12, 0.88);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top) + 56px) 12px calc(var(--safe-bottom) + 12px);
}

.review-lightbox-close {
    position: absolute;
    top: calc(var(--safe-top) + 10px);
    right: 14px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 250, 244, 0.16);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    appearance: none;
}

.review-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    border-radius: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.46;
    transform: none;
}

[hidden] {
    display: none !important;
}

@media (max-width: 640px) {
    .entry-overlay {
        padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 206px);
    }

    .entry-card {
        padding: 20px 18px 18px;
        border-radius: 24px;
    }

    .entry-name-input {
        min-height: 48px;
    }

    .control-bar {
        gap: 12px;
        padding-bottom: calc(var(--safe-bottom) + clamp(60px, 12vh, 98px));
    }

    .control-button {
        width: 72px;
        height: 72px;
        border-radius: 20px;
    }

    .shutter-button {
        width: 102px;
        height: 102px;
    }

    .zoom-control {
        width: min(84vw, 320px);
        bottom: calc(var(--safe-bottom) + var(--control-lift) + 104px);
    }

    .review-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .review-device-time {
        text-align: left;
    }


    .review-header {
        padding: 0 10px;
    }

    .review-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }


    .status-chip {
        font-size: 0.72rem;
        letter-spacing: 0.08em;
    }
}
