/* ============ 主题 CSS 变量 ============ */
:root {
    --accent: #e6c15a;
    --glow: rgba(252, 238, 167, 0.55);
    --bg-radial: radial-gradient(circle at center, #0f2027 0%, #091524 60%, #050d1a 100%);
    --title-top: #ffffff;
    --title-bottom: #eebb66;
}

/* ============ 基础布局 ============ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg-radial);
    background-color: #050d1a;
    font-family: 'Georgia', 'Times New Roman', 'PingFang SC', 'Microsoft YaHei', serif;
    color: #fff;
    user-select: none;
}

#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
}

input[type='file'] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ============ 首屏加载遮罩 ============ */
#loader {
    position: fixed;
    inset: 0;
    background: #050d1a;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.7s ease-out;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 1.5px solid rgba(230, 193, 90, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader-text {
    color: var(--accent);
    font-size: 13px;
    letter-spacing: 4px;
    margin-top: 18px;
    text-transform: uppercase;
}

/* ============ 火漆印章拆礼盒开场页 ============ */
#gift-cover {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at center, rgba(8, 16, 32, 0.58) 0%, rgba(4, 8, 18, 0.86) 100%);
    backdrop-filter: blur(8px);
    transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1), transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

#gift-cover[hidden] {
    display: none;
}

#gift-cover.opening {
    opacity: 0;
    transform: scale(1.12);
    pointer-events: none;
}

.envelope-card {
    max-width: 460px;
    width: 100%;
    padding: 42px 34px 36px;
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(18, 22, 38, 0.92), rgba(9, 12, 22, 0.96));
    border: 1px solid rgba(230, 193, 90, 0.42);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.78), 0 0 45px var(--glow);
    text-align: center;
    position: relative;
}

.envelope-badge {
    font-size: 11px;
    letter-spacing: 3.5px;
    color: var(--accent);
    opacity: 0.9;
    margin-bottom: 14px;
}

.envelope-sub {
    margin: 0;
    font-size: 13px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 1px;
}

.envelope-to {
    margin: 10px 0 18px;
    font-size: clamp(26px, 5vw, 34px);
    font-weight: 400;
    letter-spacing: 3px;
    color: #fff8e7;
    text-shadow: 0 0 28px var(--glow);
}

.envelope-divider {
    width: 90px;
    height: 1px;
    margin: 0 auto 18px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.envelope-desc {
    margin: 0 0 28px;
    font-size: 13.5px;
    line-height: 1.85;
    color: rgba(255, 255, 255, 0.76);
}

.envelope-desc strong {
    color: var(--accent);
    font-weight: 500;
}

.wax-seal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 32px;
    border-radius: 999px;
    border: 1px solid rgba(255, 120, 132, 0.85);
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 214, 220, 0.35), transparent 45%),
        linear-gradient(135deg, #c8102e, #8f0a1f);
    color: #fff3f0;
    font-size: 15px;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 0 28px rgba(215, 38, 61, 0.45), inset 0 0 18px rgba(80, 0, 10, 0.55);
    transition: all 0.35s ease;
    animation: pulse-glow-red 2.4s ease-in-out infinite;
}

.wax-seal-btn:hover {
    transform: translateY(-2px) scale(1.03);
    background: linear-gradient(135deg, #e0223c, #a30f27);
    color: #fff;
}

@keyframes pulse-glow-red {
    0%, 100% { box-shadow: 0 0 20px rgba(215, 38, 61, 0.4), inset 0 0 18px rgba(80, 0, 10, 0.55); }
    50% { box-shadow: 0 0 38px rgba(230, 60, 80, 0.6), inset 0 0 18px rgba(80, 0, 10, 0.55); }
}

.envelope-from {
    margin: 22px 0 0;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1.5px;
}

/* ============ 主界面 UI 层 ============ */
#ui-layer {
    position: fixed;
    inset: 0;
    z-index: 15;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 28px 24px 26px;
    transition: opacity 0.45s ease;
}

.header-block {
    align-self: flex-start;
    text-align: left;
    margin-left: clamp(6px, 4vw, 72px);
    margin-top: clamp(42px, 13vh, 150px);
    max-width: min(52vw, 560px);
}

.title-eyebrow {
    margin: 0 0 16px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(9px, 0.95vw, 13px);
    letter-spacing: 0.46em;
    color: var(--accent);
    opacity: 0.72;
}

h1#main-title {
    margin: 0;
    font-size: clamp(32px, 4.8vw, 66px);
    font-weight: 400;
    line-height: 1.16;
    letter-spacing: 0.06em;
    text-shadow: 0 0 42px var(--glow);
    background: linear-gradient(to bottom, var(--title-top), var(--title-bottom));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dedication-line {
    margin: 20px 0 0;
    font-size: 14px;
    letter-spacing: 3px;
    color: var(--accent);
    text-shadow: 0 0 18px var(--glow);
    opacity: 0.92;
}

/* 右上角工具栏 */
.top-right-bar {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    z-index: 25;
}

.theme-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 11px;
    border-radius: 999px;
    background: rgba(12, 16, 28, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(8px);
}

.theme-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    cursor: pointer;
    padding: 0;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.theme-dot.gold { background: linear-gradient(135deg, #fff1b8, #d4af37); }
.theme-dot.rose { background: linear-gradient(135deg, #ffd6e6, #ff7eb3); }
.theme-dot.ice  { background: linear-gradient(135deg, #f4f9ff, #8fb8f0 55%, #d7263d); }

.theme-dot.active,
.theme-dot:hover {
    transform: scale(1.22);
    border-color: #fff;
    box-shadow: 0 0 12px var(--glow);
}

.pill-btn {
    pointer-events: auto;
    background: rgba(14, 18, 30, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #f7f2e7;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12.5px;
    letter-spacing: 1px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.28s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.pill-btn:hover,
.pill-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 16px var(--glow);
}

.pill-btn.highlight {
    background: linear-gradient(135deg, rgba(230, 193, 90, 0.28), rgba(230, 193, 90, 0.1));
    border-color: var(--accent);
    color: #fff8e6;
}

.pill-btn.highlight:hover {
    background: var(--accent);
    color: #111;
}

/* 底部水晶胶囊控制栏 */
.action-dock {
    pointer-events: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(10, 14, 26, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
}

.dock-btn {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.82);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.dock-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.dock-btn.active {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    box-shadow: 0 0 14px var(--glow);
}

.dock-sep {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 2px;
}

/* ============ 微信内打开友好提示胶囊 ============ */
.wx-tip {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(14, 18, 32, 0.92);
    border: 1px solid var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 18px var(--glow);
    color: #fff6e5;
    font-size: 12px;
    line-height: 1.5;
    backdrop-filter: blur(10px);
}

.wx-tip[hidden] {
    display: none;
}

.wx-tip strong {
    color: var(--accent);
}

.wx-tip-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

/* ============ 后台无感隐形镜头 + 底部灵动手势微光胶囊 ============ */
.stealth-webcam {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0.001;
    pointer-events: none;
    z-index: -1;
}

.bottom-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* 底部诗意标语（极细英文大写间距 + 柔和中文诗句） */
.mode-poetry {
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
    margin-bottom: 2px;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.poetry-en {
    font-size: 9.5px;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.72;
}

.poetry-zh {
    font-size: 13.5px;
    letter-spacing: 0.22em;
    color: rgba(255, 250, 240, 0.88);
    text-shadow: 0 0 16px var(--glow);
}

.gesture-hud {
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(10, 14, 26, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    letter-spacing: 0.8px;
    backdrop-filter: blur(8px);
    opacity: 0.62;
    transition: all 0.3s ease;
}

.gesture-hud[hidden] {
    display: none;
}

/* 正在加载或实时捕捉到手势动作时泛起柔和主题微光 */
.gesture-hud.sensing {
    opacity: 1;
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(14, 18, 32, 0.78);
    box-shadow: 0 0 18px var(--glow);
    transform: translateY(-1px);
}

.gesture-hud.retryable {
    pointer-events: auto;
    cursor: pointer;
    opacity: 1;
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(14, 18, 32, 0.85);
    box-shadow: 0 0 16px var(--glow);
}

#debug-info {
    display: none;
    font-size: 10px;
    font-family: ui-monospace, Menlo, monospace;
    opacity: 0.75;
}

.debug-visible #debug-info {
    display: inline;
}

/* 按 H 清屏录视频 */
.ui-hidden-all #ui-layer,
.ui-hidden-all #studio-drawer {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.ui-hidden-all .top-right-bar,
.ui-hidden-all .action-dock {
    pointer-events: none !important;
}

/* ============ 链接失效 / 未找到提示遮罩 ============ */
.expired-overlay {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at center, #0b1628 0%, #050a14 100%);
}

.expired-overlay[hidden] {
    display: none;
}

.expired-card {
    max-width: 400px;
    width: 100%;
    padding: 36px 28px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(14, 18, 32, 0.92);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72), 0 0 32px rgba(150, 190, 255, 0.14);
}

.expired-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.expired-card h2 {
    margin: 0 0 12px;
    font-size: 19px;
    font-weight: 500;
    color: #fff8ea;
    letter-spacing: 1px;
}

.expired-card p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.65);
}

/* ============ 弹窗通用（专属信笺 + 手势指南） ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(5, 10, 20, 0.72);
    backdrop-filter: blur(8px);
    animation: fade-in 0.35s ease both;
}

.modal-backdrop[hidden] {
    display: none;
}

.letter-paper,
.onboarding-card,
.poster-card {
    max-width: 450px;
    width: 100%;
    padding: 34px 30px;
    border-radius: 14px;
    border: 1px solid rgba(230, 193, 90, 0.42);
    background: linear-gradient(165deg, rgba(18, 22, 36, 0.95), rgba(9, 12, 22, 0.98));
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), 0 0 36px var(--glow);
}

.poster-card {
    max-width: min(460px, 92vw);
    padding: 22px 18px 20px;
    text-align: center;
}

.poster-tip {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 248, 232, 0.88);
}

.poster-tip strong {
    color: var(--accent);
}

.poster-frame {
    margin: 0 auto 16px;
    padding: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

/* 必须显式覆盖 body 的 user-select: none，确保 iOS/微信长按弹出原生保存菜单 */
#poster-img {
    display: block;
    max-width: 100%;
    max-height: 68vh;
    margin: 0 auto;
    border-radius: 8px;
    object-fit: contain;
    -webkit-touch-callout: default;
    -webkit-user-select: auto;
    user-select: auto;
    pointer-events: auto;
}

.letter-ornament {
    text-align: center;
    font-size: 10.5px;
    letter-spacing: 3px;
    color: var(--accent);
    margin-bottom: 18px;
}

.letter-paper h3 {
    margin: 0 0 14px;
    font-size: 20px;
    font-weight: 500;
    color: #fff6e0;
}

.letter-paper p#letter-body {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.95;
    color: rgba(255, 255, 255, 0.86);
    white-space: pre-wrap;
}

.letter-sign {
    text-align: right;
    font-style: italic;
    color: var(--accent);
    font-size: 14px;
    margin: 0 0 24px;
}

.modal-close-btn {
    display: flex;
    margin: 0 auto;
    min-width: 150px;
}

.onboarding-card {
    text-align: center;
}

.onboarding-card h2 {
    margin: 0 0 22px;
    color: #fff6e0;
    font-size: 19px;
    font-weight: 400;
    letter-spacing: 2px;
}

.gesture-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gesture-list li {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: center;
    gap: 3px 14px;
    text-align: left;
}

.gesture-emoji {
    grid-row: 1 / 3;
    font-size: 28px;
    text-align: center;
}

.gesture-list strong {
    color: var(--accent);
    font-size: 13.5px;
}

.gesture-list li > span:last-child {
    color: rgba(255, 255, 255, 0.68);
    font-size: 12.5px;
}

.onboarding-note {
    margin: 0 0 22px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    line-height: 1.75;
}

.onboarding-note kbd {
    padding: 1px 6px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--accent);
    font-size: 11px;
}

/* ============ 右侧在线定制工作台抽屉 ============ */
.studio-drawer {
    position: fixed;
    top: 74px;
    right: 24px;
    bottom: 92px;
    width: 340px;
    max-width: calc(100vw - 32px);
    z-index: 60;
    background: rgba(12, 16, 28, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fade-in 0.25s ease both;
}

.studio-drawer[hidden] {
    display: none;
}

.studio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.studio-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 1px;
}

.close-x {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.studio-body {
    padding: 16px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.field-label input,
.field-label select,
.field-label textarea {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.field-label select option {
    background: #121726;
    color: #fff;
}

.field-label input:focus,
.field-label select:focus,
.field-label textarea:focus {
    border-color: var(--accent);
}

.upload-zone {
    padding: 12px;
    border-radius: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.03);
}

.upload-tip {
    margin: 0 0 10px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.68);
}

.studio-btn-row {
    display: flex;
    gap: 8px;
}

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

.full-btn {
    width: 100%;
    flex: 1;
    font-size: 12px;
    padding: 9px 12px;
}

.studio-footnote {
    margin: 4px 0 0;
    font-size: 11px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.45);
}

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

/* ============ 手机小屏自适应 ============ */
@media (max-width: 760px) {
    .top-right-bar {
        top: 14px;
        right: 12px;
        left: 12px;
        justify-content: space-between;
    }

    .header-block {
        align-self: center;
        text-align: center;
        margin-left: 0;
        margin-top: clamp(64px, 12vh, 110px);
        max-width: 88vw;
    }

    .title-eyebrow {
        letter-spacing: 0.34em;
        margin-bottom: 12px;
    }

    .gesture-hud {
        font-size: 11px;
        padding: 4px 12px;
    }

    .poetry-en {
        font-size: 8px;
        letter-spacing: 0.3em;
    }

    .poetry-zh {
        font-size: 11.5px;
        letter-spacing: 0.16em;
    }

    .action-dock {
        border-radius: 18px;
        padding: 8px 10px;
        gap: 6px;
    }

    .dock-sep {
        display: none;
    }

    .dock-btn {
        font-size: 11.5px;
        padding: 6px 10px;
    }

    .studio-drawer {
        top: 62px;
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 84px;
    }
}
