:root {
    --mirror-gold: #d6b46a;
    --mirror-gold-soft: #f2dca6;
    --mirror-ink: #020617;
    --mirror-deep: #091739;
    --mirror-deeper: #050c22;
    --mirror-cyan: #3ed5ff;
    --mirror-text: #f8fafc;
}

* {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

.mirror-page {
    margin: 0;
    min-height: 100vh;
    color: var(--mirror-text);
    font-family: "Georgia", "Times New Roman", serif;
    background:
        radial-gradient(circle at 12% 18%, rgba(62, 213, 255, 0.18), transparent 28%),
        radial-gradient(circle at 85% 12%, rgba(122, 74, 255, 0.16), transparent 26%),
        radial-gradient(circle at 80% 78%, rgba(214, 180, 106, 0.12), transparent 30%),
        linear-gradient(160deg, var(--mirror-ink) 0%, var(--mirror-deeper) 45%, var(--mirror-deep) 100%);
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

html,
body {
    overscroll-behavior: none;
}

.fx-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
}

.mirror-root {
    position: fixed;
    inset: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mirror-preloader {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.65), rgba(2, 6, 23, 0.95));
}

.preloader-card {
    width: min(460px, calc(100% - 28px));
    border-radius: 16px;
    border: 1px solid rgba(214, 180, 106, 0.45);
    background: rgba(7, 15, 42, 0.9);
    padding: 18px;
    text-align: center;
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
}

.preloader-card h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff8e1;
}

.preloader-card p {
    margin: 8px 0 12px;
    color: #cbd5e1;
}

.preloader-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
    border: 1px solid rgba(214, 180, 106, 0.35);
}

.preloader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3ed5ff, #d6b46a);
    transition: width 0.25s ease;
}

.mirror-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.22;
    filter: saturate(1.2) contrast(1.05);
}

.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(2, 6, 23, 0.08) 28%, rgba(2, 6, 23, 0.72) 100%);
    z-index: 2;
}

.mirror-layer {
    position: absolute;
    inset: 0;
    height: 100%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 14px;
    pointer-events: none;
}

.mirror-layer>* {
    pointer-events: auto;
}

.panel {
    width: min(780px, 100%);
    border-radius: 18px;
    border: 1px solid rgba(214, 180, 106, 0.42);
    background:
        linear-gradient(140deg, rgba(8, 20, 52, 0.86), rgba(5, 12, 34, 0.92)),
        radial-gradient(circle at 20% 30%, rgba(62, 213, 255, 0.08), transparent 35%);
    box-shadow:
        0 26px 44px rgba(0, 0, 0, 0.46),
        inset 0 0 0 1px rgba(242, 220, 166, 0.18);
    padding: 18px;
    backdrop-filter: blur(4px);
}

.panel::before,
.panel::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(214, 180, 106, 0.5);
    pointer-events: none;
}

.panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: auto;
    max-height: 90vh;
    margin: auto;
}

.minimal-panel {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    width: min(820px, 100%);
    padding: 8px;
}

.minimal-panel::before,
.minimal-panel::after {
    display: none;
}

.panel::before {
    top: 10px;
    left: 10px;
    border-right: none;
    border-bottom: none;
}

.panel::after {
    bottom: 10px;
    right: 10px;
    border-left: none;
    border-top: none;
}

.panel-center {
    text-align: center;
}

.panel-center>.magic-btn {
    margin-top: 20px;
}

.mirror-auth-form {
    width: min(460px, 100%);
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mirror-input {
    min-height: 46px;
    border-radius: 12px;
    border: 1px solid rgba(62, 213, 255, 0.38);
    background: rgba(4, 14, 36, 0.85);
    color: #e2e8f0;
    padding: 10px 12px;
    font-size: 0.98rem;
}

.mirror-input::placeholder {
    color: #94a3b8;
}

.panel h1,
.panel h2 {
    margin: 0;
    color: #fff9e6;
    font-size: clamp(1.4rem, 3.3vw, 2.1rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel p {
    margin: 10px 0 16px;
    color: #dbeafe;
    font-size: clamp(0.92rem, 1.7vw, 1.06rem);
}

#waitSubtitle {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: clamp(1.8rem, 5.5vw, 3.2rem);
    line-height: 1.2;
    font-weight: 700;
    text-align: center;
}

#waitLayer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.wait-panel {
    width: min(100%, 1200px);
    height: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.wait-actions {
    margin-top: 16px;
}

.wait-subtitle-fade-in-up {
    animation: waitSubtitleFadeInUp 380ms ease-out both;
}

@keyframes waitSubtitleFadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.magic-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 12px 18px;
    border-radius: 999px;
    border: 1px solid rgba(214, 180, 106, 0.68);
    background:
        linear-gradient(180deg, rgba(16, 33, 89, 0.9), rgba(11, 23, 66, 0.95));
    color: #f5deb1;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(1, 8, 27, 0.45), inset 0 0 0 1px rgba(242, 220, 166, 0.22);
    transition: transform 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.magic-btn:hover {
    transform: translateY(-1px);
    border-color: var(--mirror-gold-soft);
    filter: brightness(1.05);
}

.magic-btn.ghost {
    background: rgba(10, 26, 74, 0.5);
    color: #dbeafe;
    border-color: rgba(62, 213, 255, 0.45);
}

.mini-danger {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 1px solid rgba(248, 113, 113, 0.45);
    background: rgba(127, 29, 29, 0.7);
    color: #fee2e2;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

.preview-wrap {
    margin-top: 12px;
    position: relative;
}

#mirrorForm {
    display: flex;
    flex-direction: column;
    min-height: min(78vh, 620px);
}

.mirror-form-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 10px;
}

.form-bottom-controls {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.mirror-upload-btn {
    align-self: center;
    width: min(420px, 100%);
}

.camera-panel {
    width: min(100%, 560px);
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid rgba(62, 213, 255, 0.28);
    background: rgba(2, 6, 23, 0.55);
    padding: 10px;
}

.camera-preview {
    width: 100%;
    aspect-ratio: 4 / 5;
    max-height: 65vh;
    object-fit: cover;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.85);
}

.camera-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.camera-select {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(62, 213, 255, 0.45);
    background: rgba(8, 18, 52, 0.95);
    color: #dbeafe;
    font-size: 0.95rem;
    padding: 10px 12px;
    text-align: center;
    text-align-last: center;
}

.mirror-preview {
    width: min(100%, 520px);
    max-height: 54vh;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 16px 30px rgba(2, 6, 23, 0.5);
    display: block;
    margin: 0 auto;
}

#resultLayer {
    align-items: center;
    padding: 10px;
}

.result-panel {
    width: min(100%, 1300px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 15px;
}

.result-preview {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 16px;
}

.result-actions {
    margin-top: 0;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
    align-content: end;
    width: min(620px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.prompt-preview-wrap {
    width: min(100%, 520px);
    margin: 0 auto 12px;
}

.prompt-btn {
    min-height: 52px;
    padding: 12px;
    border-radius: 999px;
    border: 1px solid rgba(214, 180, 106, 0.6);
    background: linear-gradient(180deg, rgba(13, 31, 84, 0.85), rgba(8, 18, 52, 0.95));
    color: #f2dca6;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(242, 220, 166, 0.2);
}

.prompt-btn:hover {
    border-color: rgba(62, 213, 255, 0.7);
    color: #e0f2fe;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 10px;
}

.actions.center {
    justify-content: center;
}

.feedback {
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 0.92rem;
}

.feedback.success {
    background: rgba(22, 101, 52, 0.78);
    border: 1px solid rgba(34, 197, 94, 0.5);
}

.feedback.error {
    background: rgba(127, 29, 29, 0.78);
    border: 1px solid rgba(239, 68, 68, 0.48);
}

.operator-hotspot {
    position: fixed;
    top: 0;
    left: 0;
    width: 72px;
    height: 72px;
    z-index: 40;
    border: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
    background: transparent;
    touch-action: manipulation;
}

.operator-layer {
    position: fixed;
    inset: 0;
    z-index: 75;
    display: grid;
    place-items: center;
    background: rgba(2, 6, 23, 0.82);
    padding: 14px;
}

.operator-modal {
    width: min(420px, 100%);
    border-radius: 14px;
    border: 1px solid rgba(214, 180, 106, 0.52);
    background: rgba(6, 15, 42, 0.96);
    padding: 14px;
    box-shadow: 0 24px 46px rgba(0, 0, 0, 0.48);
}

.operator-modal h3 {
    margin: 0;
    color: #fff8e1;
    font-size: 1.2rem;
}

.operator-modal p {
    margin: 8px 0 10px;
    color: #dbeafe;
}

@media (max-width: 860px) {
    .panel {
        padding: 14px;
    }

    .actions {
        width: 100%;
    }

    .magic-btn,
    .magic-btn.ghost {
        width: 100%;
    }
}