/* ============================================================
   幸福拍貼機 · 共用設計系統 v2「軟糖藍」
   柔和天藍背景 × 白色圓角卡片 × 圓體字 × 手繪吉祥物
   ============================================================ */

:root {
    /* ─ 主色 ─ */
    --sky:        #AFC9EC;
    --sky-deep:   #7FA6DC;
    --sky-mid:    #C9DCF5;
    --sky-soft:   #E7F0FC;
    --card:       #FFFFFF;
    --card-alt:   #F4F8FD;
    --ink:        #23262E;
    --ink-mid:    #6B7688;
    --ink-soft:   #9AA6B8;
    --pink:       #F3A8BC;
    --pink-deep:  #E88AA3;
    --pink-soft:  #FDE2E9;
    --cream:      #FFF4DE;
    --mint:       #9FD8C4;
    --danger:     #E4695F;

    /* ─ 圓角 / 陰影 ─ */
    --r-xl:  30px;
    --r-lg:  24px;
    --r-md:  16px;
    --r-sm:  11px;
    --r-pill: 999px;
    --sh-card: 0 8px 22px rgba(72, 108, 163, 0.13);
    --sh-pop:  0 14px 32px rgba(72, 108, 163, 0.20);
    --sh-soft: 0 3px 10px rgba(72, 108, 163, 0.10);

    /* ─ 舊變數對應（頁面內嵌樣式仍在使用）─ */
    --bg-pink:         var(--sky);
    --bg-pink-deep:    var(--sky-deep);
    --cream-light:     var(--card-alt);
    --title-purple:    var(--sky-deep);
    --title-purple-dk: var(--ink-mid);
    --outline:         var(--ink);
    --coral:           var(--pink-deep);
    --pink-accent:     var(--pink);
    --blue-soft:       var(--sky-deep);
    --yellow-folder:   var(--cream);
    --yellow-dark:     #D9B26A;
    --green-ok:        var(--mint);
    --shadow:          rgba(72,108,163,0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: 'Fredoka', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background: var(--sky);
    color: var(--ink);
    min-height: 100vh;
    padding: 18px 16px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 背景：柔和光暈，不用格線 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(60% 40% at 15% 0%,  rgba(255,255,255,0.55) 0%, transparent 70%),
        radial-gradient(50% 35% at 95% 12%, rgba(253,226,233,0.55) 0%, transparent 72%),
        radial-gradient(70% 45% at 50% 105%, rgba(255,255,255,0.40) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
body::after { content: none; }

.hidden { display: none !important; }

/* ─ 版面容器 ────────────────────────────────── */
.app-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}
.win-body { padding: 0; text-align: center; }

/* ─ 頂部品牌列 ──────────────────────────────── */
.win-titlebar {
    background: transparent;
    border: none;
    padding: 2px 4px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--ink);
    font-family: 'Fredoka', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.6px;
}
.win-title-left { display: flex; align-items: center; gap: 8px; }
.win-title-left .favicon {
    width: 22px; height: 22px;
    background: var(--card);
    border: 2.5px solid var(--ink);
    border-radius: 8px;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}
.win-title-left .favicon::after {
    content: '';
    position: absolute;
    inset: 4px;
    background: var(--pink);
    border-radius: 50%;
}
.win-controls, .mini-btns, .win-btn { display: none !important; }

/* ─ 標題 ────────────────────────────────────── */
h1 {
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-weight: 700;
    color: var(--ink);
    font-size: 2.05rem;
    margin: 0;
    letter-spacing: 1px;
    line-height: 1.2;
}
h1 .cursor {
    display: inline-block;
    width: 10px; height: 10px;
    background: var(--pink);
    border-radius: 50%;
    vertical-align: 4px;
    margin-left: 6px;
    animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}
@keyframes blink { 50% { opacity: 1; } }

.subtitle {
    font-size: 0.84rem;
    color: var(--ink-mid);
    letter-spacing: 0.3px;
    margin: 8px 0 0;
    font-weight: 500;
}
.divider {
    width: 52px; height: 6px;
    background: var(--pink);
    border: none;
    border-radius: var(--r-pill);
    margin: 14px auto 2px;
}

/* 吉祥物 */
.mascot {
    display: block;
    width: 290px;
    height: auto;               /* 高度一律由寬度推算 */
    aspect-ratio: 1608 / 674;    /* logo.svg 的實際比例，避免載入前後跳動或被拉伸 */
    object-fit: contain;
    max-width: 80%;
    margin: 40px auto;
    filter: drop-shadow(0 12px 20px rgba(72,108,163,0.20));
    animation: float 5s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-8px) rotate(1deg); }
}

/* ─ 卡片 ────────────────────────────────────── */
.panel,
.message-wrapper,
.consent-wrapper {
    background: var(--card);
    border: none;
    border-radius: var(--r-lg);
    margin: 16px 0;
    box-shadow: var(--sh-card);
    overflow: hidden;
    text-align: left;
}
.panel-titlebar {
    background: transparent;
    border: none;
    padding: 15px 18px 2px;
    color: var(--ink);
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-titlebar > span:first-child { display: flex; align-items: center; gap: 7px; }
.panel-titlebar > span:first-child::before {
    content: '';
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--pink);
    flex-shrink: 0;
}
.panel-body,
.message-wrapper .wrap-body { padding: 12px 16px 16px; }

/* ─ 按鈕 ────────────────────────────────────── */
.btn-main {
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-weight: 600;
    background: var(--ink);
    color: #fff;
    border: none;
    padding: 15px 20px;
    border-radius: var(--r-pill);
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    box-shadow: var(--sh-card);
    letter-spacing: 1px;
    margin-top: 12px;
    transition: transform 0.15s cubic-bezier(.34,1.56,.64,1), box-shadow 0.15s, opacity 0.15s;
}
.btn-main:hover  { transform: translateY(-2px); box-shadow: var(--sh-pop); }
.btn-main:active { transform: translateY(1px) scale(0.99); box-shadow: var(--sh-soft); }
.btn-main:disabled {
    background: var(--sky-mid);
    color: #fff;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.btn-secondary {
    background: var(--card);
    color: var(--ink);
    box-shadow: inset 0 0 0 2.5px var(--sky-mid), var(--sh-soft);
}
.btn-secondary:hover { box-shadow: inset 0 0 0 2.5px var(--sky-deep), var(--sh-card); }
.btn-blue { background: var(--sky-deep); color: #fff; }
.btn-pink { background: var(--pink); color: #fff; }

/* ─ 模板選擇器 ──────────────────────────────── */
.template-selector {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 6px 2px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.template-selector::-webkit-scrollbar { height: 6px; }
.template-selector::-webkit-scrollbar-track { background: var(--sky-soft); border-radius: var(--r-pill); }
.template-selector::-webkit-scrollbar-thumb { background: var(--sky-deep); border-radius: var(--r-pill); }

.tpl-container {
    flex: 0 0 116px;
    max-width: 116px;
    cursor: pointer;
    text-align: center;
    position: relative;
    padding-top: 6px;
}
.tpl-btn-wrapper {
    width: 100%;
    height: 118px;
    background: var(--sky-soft);
    border: 2.5px solid transparent;
    border-radius: var(--r-md);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: none;
    padding: 8px;
    transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), border-color 0.18s, box-shadow 0.18s;
}
.tpl-btn-wrapper::before { content: none; }
.tpl-btn,
.tpl-btn-wrapper canvas,
.tpl-btn-wrapper img {
    max-width: 100%;
    max-height: 100%;
    background: #fff;
    border: none;
    border-radius: var(--r-sm);
    padding: 0;
    box-shadow: var(--sh-soft);
    position: relative;
    z-index: 2;
}
.tpl-container.active .tpl-btn-wrapper {
    background: var(--pink-soft);
    border-color: var(--pink);
    transform: translateY(-3px);
    box-shadow: var(--sh-card);
}
.tpl-label {
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--ink-mid);
    margin-top: 8px;
    letter-spacing: 0.2px;
}
.tpl-container.active .tpl-label { color: var(--ink); font-weight: 600; }
.check-badge {
    position: absolute;
    top: -2px; right: -2px;
    width: 24px; height: 24px;
    background: var(--pink);
    border: 2.5px solid #fff;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    z-index: 5;
    box-shadow: var(--sh-soft);
}
.tpl-container.active .check-badge { display: flex; }

/* ─ 照片格子（拍貼機）───────────────────────── */
.photo-slots-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 4px 0;
}
.photo-slot {
    width: 82px; height: 82px;
    background: var(--sky-soft);
    border: 2.5px dashed var(--sky-deep);
    border-radius: var(--r-md);
    position: relative;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    overflow: hidden;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.18s;
}
.photo-slot:hover { transform: translateY(-3px); box-shadow: var(--sh-card); }
.photo-slot::after {
    content: '+';
    font-family: 'Fredoka', sans-serif;
    font-size: 30px;
    font-weight: 400;
    color: var(--sky-deep);
    opacity: 0.9;
    line-height: 1;
}
.photo-slot.filled {
    border: 2.5px solid var(--pink);
    box-shadow: var(--sh-soft);
}
.photo-slot.filled::after { display: none; }
.slot-number {
    position: absolute;
    top: 5px; left: 5px;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink);
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 50%;
    width: 20px; height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 2;
    box-shadow: var(--sh-soft);
}
.photo-slot.filled .slot-number { background: var(--pink); color: #fff; }
.slot-replace-overlay {
    display: none;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(35,38,46,0.72);
    color: #fff;
    font-size: 0.62rem;
    padding: 4px 0;
    font-weight: 600;
    text-align: center;
    border: none;
    letter-spacing: 0.5px;
}
.photo-slot.filled .slot-replace-overlay { display: block; }

/* ─ 表單 ────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label,
.message-wrapper label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}
.field label .opt { font-weight: 400; color: var(--ink-soft); font-size: 0.72rem; }
.field input,
.message-wrapper input,
input[type="text"], input[type="email"], input[type="number"], select {
    width: 100%;
    padding: 12px 14px;
    border: 2.5px solid transparent;
    border-radius: var(--r-md);
    font-size: 0.95rem;
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    background: var(--card-alt);
    color: var(--ink);
    outline: none;
    box-shadow: none;
    transition: border-color 0.15s, background 0.15s;
}
.field input:focus,
.message-wrapper input:focus,
input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus, select:focus {
    background: #fff;
    border-color: var(--pink);
}
.field input::placeholder, .message-wrapper input::placeholder { color: var(--ink-soft); }
.field .hint, .hint {
    font-size: 0.73rem;
    color: var(--ink-soft);
    margin-top: 6px;
    line-height: 1.6;
}
.err-text {
    color: var(--danger);
    font-size: 0.76rem;
    margin-top: 7px;
    font-weight: 600;
    min-height: 16px;
}

/* 同意勾選 */
.consent-wrapper { padding: 14px 16px; margin: 14px 0; }
.consent-wrapper label {
    color: var(--ink);
    font-weight: 500;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    margin: 0;
}
.consent-wrapper input[type="checkbox"] {
    width: 20px; height: 20px;
    accent-color: var(--pink);
    flex-shrink: 0;
}

/* ─ 狀態文字 ────────────────────────────────── */
#status-msg, #upload-status, #checkout-status, .loading-text, .edit-hint, .editor-hint, .preview-caption {
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-size: 0.85rem;
    color: var(--ink-mid);
    letter-spacing: 0.2px;
    font-weight: 500;
}
#status-msg, #upload-status, #checkout-status {
    min-height: 22px;
    margin-top: 12px;
    text-align: center;
}
.loading-text { padding: 16px 8px; }
.loading-text::after { content: '…'; }
.edit-hint { text-align: center; margin: 12px 0 2px; }

/* ─ 結果頁 ──────────────────────────────────── */
.result-tag {
    display: inline-block;
    padding: 7px 18px;
    background: var(--pink-soft);
    color: var(--pink-deep);
    border: none;
    border-radius: var(--r-pill);
    box-shadow: none;
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 1px;
    margin-bottom: 16px;
}
#result-preview {
    max-width: 100%;
    height: auto;
    border: none;
    border-radius: var(--r-lg);
    box-shadow: var(--sh-pop);
    background: #fff;
    display: block;
    margin: 0 auto;
    cursor: pointer;
}

/* ─ 照片編輯彈窗 ────────────────────────────── */
#photo-editor {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(35,38,46,0.45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}
.editor-box {
    width: 100%;
    max-width: 350px;
    background: var(--card);
    border: none;
    border-radius: var(--r-xl);
    box-shadow: var(--sh-pop);
    overflow: hidden;
    animation: popIn 0.28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
    from { transform: scale(0.92) translateY(12px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.editor-box .panel-titlebar { background: transparent; color: var(--ink); }
.editor-body { padding: 6px 16px 18px; text-align: center; }
.editor-stage {
    position: relative;
    display: inline-block;
    border: none;
    border-radius: var(--r-md);
    box-shadow: var(--sh-soft);
    background: var(--sky-soft);
    touch-action: none;
    overflow: hidden;
    line-height: 0;
}
#editor-canvas { display: block; touch-action: none; cursor: grab; }
#editor-canvas:active { cursor: grabbing; }
.editor-actions { display: flex; gap: 8px; margin-top: 14px; }
.editor-actions button {
    flex: 1;
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-weight: 600;
    border: none;
    border-radius: var(--r-pill);
    padding: 12px 6px;
    font-size: 0.88rem;
    cursor: pointer;
    box-shadow: var(--sh-soft);
    transition: transform 0.12s;
}
.editor-actions button:active { transform: scale(0.96); }
#editor-reupload, #editor-reset { background: var(--card-alt); color: var(--ink); }
#editor-done { background: var(--ink); color: #fff; }
.editor-hint { margin: 12px 0 0; font-size: 0.76rem; }

/* ─ 頁尾 ────────────────────────────────────── */
.site-footer {
    position: relative;
    z-index: 1;
    margin-top: 22px;
    padding: 10px 8px 4px;
    text-align: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.78rem;
    color: rgba(35,38,46,0.55);
    letter-spacing: 0.4px;
}
.site-footer a { color: rgba(35,38,46,0.75); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }

/* ─ 底部導覽列 ──────────────────────────────── */
.tabbar {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    z-index: 8000;
    width: calc(100% - 32px);
    max-width: 420px;
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(10px);
    border-radius: var(--r-pill);
    box-shadow: var(--sh-pop);
    display: flex;
    padding: 7px;
    gap: 4px;
}
.tab-item {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: var(--r-pill);
    padding: 8px 4px 7px;
    font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    position: relative;
    transition: background 0.18s, color 0.18s;
}
.tab-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.tab-item.active { background: var(--sky-soft); color: var(--ink); }
.tab-badge {
    position: absolute;
    top: 2px; right: 50%;
    margin-right: -22px;
    min-width: 19px; height: 19px;
    padding: 0 5px;
    background: var(--pink-deep);
    color: #fff;
    border: 2px solid #fff;
    border-radius: var(--r-pill);
    font-size: 0.66rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.has-tabbar { padding-bottom: 96px; }

/* ─ 小元件 ──────────────────────────────────── */
.badge-status {
    display: inline-block;
    background: var(--pink-soft);
    color: var(--pink-deep);
    border: none;
    border-radius: var(--r-pill);
    padding: 3px 12px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.order-no {
    font-family: 'Fredoka', monospace;
    font-size: 1.05rem;
    letter-spacing: 1.5px;
    font-weight: 600;
    color: var(--ink);
    background: var(--cream);
    border: none;
    border-radius: var(--r-pill);
    padding: 3px 12px;
    display: inline-block;
}
.copy-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--card-alt);
    border: none;
    border-radius: var(--r-pill);
    padding: 4px 10px;
    cursor: pointer;
    margin-left: 7px;
    color: var(--ink-mid);
    letter-spacing: 0.5px;
}
.copy-btn:hover { background: var(--sky-soft); }

@media (max-width: 380px) {
    h1 { font-size: 1.7rem; }
    .tpl-container { flex: 0 0 104px; max-width: 104px; }
    .tpl-btn-wrapper { height: 106px; }
}
