:root {
    --foto-violet: #b266ff;
    --foto-violet-bright: #d8b4fe;
    --foto-panel: rgba(13, 10, 18, 0.96);
}

[hidden] {
    display: none !important;
}

.foto-layer,
.foto-modal-layer {
    position: absolute;
    inset: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.32);
    font-family: sans-serif;
    touch-action: manipulation;
}

.foto-countdown-widget {
    position: relative;
    width: min(230px, 42vw);
    aspect-ratio: 1;
    filter: drop-shadow(0 0 22px rgba(178, 102, 255, 0.55));
}

.foto-countdown-ring {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.foto-countdown-segment {
    fill: none;
    stroke: var(--foto-violet);
    stroke-width: 11;
    stroke-linecap: round;
    stroke-dasharray: 48 312;
    transition: opacity 180ms ease, filter 180ms ease;
}

.foto-countdown-segment.is-hidden {
    opacity: 0;
    filter: blur(5px);
}

.foto-countdown-number {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: clamp(64px, 10vw, 108px);
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 0 18px rgba(178, 102, 255, 0.75);
}

#foto-flash-layer {
    position: absolute;
    inset: 0;
    z-index: 1150;
    pointer-events: none;
    background: #fff;
    opacity: 0;
}

#foto-flash-layer.is-active {
    animation: foto-flash 220ms ease-out both;
}

@keyframes foto-flash {
    0% { opacity: 0; }
    18% { opacity: 0.98; }
    100% { opacity: 0; }
}

.foto-modal-layer {
    z-index: 1200;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    padding: 20px;
    box-sizing: border-box;
}

.foto-modal-card {
    position: relative;
    width: min(820px, 94vw);
    max-height: 92vh;
    overflow: auto;
    box-sizing: border-box;
    border: 1px solid rgba(178, 102, 255, 0.65);
    border-radius: 18px;
    padding: 28px;
    color: #fff;
    background: var(--foto-panel);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.72), 0 0 34px rgba(178, 102, 255, 0.22);
}

.foto-modal-x {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 46px;
    height: 46px;
    border: 1px solid #4a3b59;
    border-radius: 50%;
    color: #fff;
    background: #201829;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.foto-modal-title {
    margin: 0 56px 6px 0;
    font-size: clamp(23px, 4vw, 34px);
}

.foto-modal-status {
    min-height: 1.3em;
    margin: 0 0 18px;
    color: #cabdd7;
}

.foto-modal-content {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr);
    gap: 24px;
    align-items: center;
}

.foto-preview-wrap {
    overflow: hidden;
    border: 1px solid #453650;
    border-radius: 12px;
    background: #000;
}

.foto-preview-wrap img {
    display: block;
    width: 100%;
    max-height: 56vh;
    object-fit: contain;
}

.foto-qr-wrap {
    display: flex;
    min-height: 250px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.foto-qr-code {
    padding: 10px;
    border-radius: 10px;
    background: #fff;
}

.foto-qr-code:empty {
    display: none;
}

.foto-qr-instruction {
    margin: 14px 0 4px;
    font-weight: 700;
}

.foto-expiry {
    margin: 4px 0;
    color: #c9bacf;
    font-size: 13px;
}

.foto-network-warning {
    margin: 10px 0 0;
    color: #ffd166;
    font-size: 12px;
    line-height: 1.35;
}

.foto-spinner {
    width: 56px;
    height: 56px;
    border: 6px solid rgba(178, 102, 255, 0.22);
    border-top-color: var(--foto-violet);
    border-radius: 50%;
    animation: foto-spin 850ms linear infinite;
}

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

.foto-modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.foto-action {
    min-height: 48px;
    padding: 12px 22px;
    border-radius: 8px;
    font-family: sans-serif;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.35px;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    -webkit-tap-highlight-color: rgba(216, 180, 254, 0.28);
}

.foto-action.hover-active,
.foto-modal-x.hover-active,
.foto-action:focus-visible,
.foto-modal-x:focus-visible {
    transform: scale(1.08);
    outline: 3px solid #fff;
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(178, 102, 255, 0.45), 0 0 28px rgba(178, 102, 255, 0.9);
    filter: brightness(1.18);
}

.foto-action:active,
.foto-modal-x:active {
    transform: scale(0.97);
}

.foto-action-primary {
    border: 1px solid var(--foto-violet);
    color: #150b1f;
    background: var(--foto-violet-bright);
}

.foto-action-secondary {
    margin-top: 18px;
    border: 1px solid #7e6c8c;
    color: #fff;
    background: #211929;
}

.foto-modal-actions .foto-action-secondary {
    margin-top: 0;
}

.foto-toast {
    position: absolute;
    left: 50%;
    bottom: 88px;
    z-index: 1300;
    max-width: min(620px, 88vw);
    transform: translateX(-50%);
    box-sizing: border-box;
    padding: 14px 18px;
    border: 1px solid #b266ff;
    border-radius: 10px;
    color: #fff;
    background: rgba(22, 15, 29, 0.96);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    font-family: sans-serif;
    font-size: 14px;
    text-align: center;
}

@media (max-width: 680px) {
    .foto-modal-card { padding: 22px 16px 18px; }
    .foto-modal-content { grid-template-columns: 1fr; }
    .foto-preview-wrap img { max-height: 34vh; }
    .foto-qr-code canvas { width: min(220px, 64vw) !important; height: auto !important; }
}

@media (prefers-reduced-motion: reduce) {
    .foto-countdown-segment { transition: none; }
    #foto-flash-layer.is-active { animation-duration: 120ms; }
}
