:root {
    --primary: #fff;
    --radius: 24px;
    --text-color: #fff;
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    background: #111;
    color: var(--text-color);
}

/* 智能選臉主背景 */
#main-background {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: var(--face-x, 50%) var(--face-y, 50%);
    z-index: 0;
    transition: background-image 0.5s ease;
}

/* 主背景微暗化，降低模糊度以清楚顯示曼希 */
.glass-layer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1;
}

.app-wrapper {
    position: relative;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Header */
.hub-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.logo {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.search-container {
    width: 100%;
    max-width: 600px;
}

#search-input {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.2rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    background: var(--glass-bg);
    color: #fff;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    outline: none;
    transition: all 0.3s ease;
}

#search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#search-input:focus {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 20px rgba(255,255,255,0.2);
}

.category-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: 0.3s;
}

.category-btn:hover, .category-btn.active {
    background: rgba(255, 255, 255, 0.4);
}

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* 透明按鈕（包含半透明曼希背景圖） */
.app-card {
    position: relative;
    height: 140px;
    background-color: var(--glass-bg);
    background-size: cover;
    background-position: var(--face-x, 50%) var(--face-y, 50%);
    background-repeat: no-repeat;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.3s, filter 0.3s;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

.app-card:hover {
    transform: translateY(-5px) scale(1.02);
    filter: brightness(1.2);
}

.app-title {
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 2;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
    pointer-events: none;
}

.app-category {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 5px;
    z-index: 2;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* 小曼希點綴裝飾 (1-3個透明縮圖) */
.manxi-decor {
    position: absolute;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    opacity: 0.85;
    transition: transform 0.3s ease;
}

.app-card:hover .manxi-decor {
    transform: scale(1.15);
}

/* ==================================
   SPA Routing & Modules
================================== */
.hidden { display: none !important; }

#module-container {
    position: relative; z-index: 2;
    max-width: 1400px; margin: 0 auto; padding: 40px 20px;
    display: flex; flex-direction: column; gap: 30px;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.glass-btn {
    align-self: flex-start;
    padding: 12px 24px;
    background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius);
    color: white; font-size: 1.1rem; cursor: pointer;
    backdrop-filter: blur(10px); transition: 0.3s;
}
.glass-btn:hover { background: rgba(255,255,255,0.4); transform: translateX(-5px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

/* ==================================
   互動助手 (Assistant)
================================== */
#manxi-assistant {
    position: fixed; bottom: 30px; right: 30px; z-index: 100;
    display: flex; flex-direction: column; align-items: flex-end; gap: 15px;
}
#assistant-avatar {
    width: 150px; height: 150px;
    background-size: contain; background-repeat: no-repeat; background-position: bottom right;
    cursor: pointer; transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
}
#assistant-avatar:hover { transform: scale(1.1) rotate(-3deg); }

#assistant-bubble {
    background: rgba(255, 255, 255, 0.25); border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    padding: 15px 25px; border-radius: 20px; border-bottom-right-radius: 0;
    max-width: 280px; font-size: 1rem; line-height: 1.6; color: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3); text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes popIn { from { transform: scale(0); transform-origin: bottom right; } to { transform: scale(1); transform-origin: bottom right; } }

/* ==================================
   曼希藝廊 (Gallery)
================================== */
.masonry-gallery { width: 100%; column-count: 4; column-gap: 20px; }
@media (max-width: 1200px) { .masonry-gallery { column-count: 3; } }
@media (max-width: 800px) { .masonry-gallery { column-count: 2; } }
@media (max-width: 500px) { .masonry-gallery { column-count: 1; } }

.gallery-item {
    break-inside: avoid; margin-bottom: 20px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 16px;
    overflow: hidden; cursor: zoom-in; transition: transform 0.3s;
    min-height: 100px; /* Placeholder span */
}
.gallery-item:hover { transform: scale(1.02); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.gallery-item img {
    width: 100%; display: block; opacity: 0; transition: opacity 0.5s ease;
}

#lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 999;
    display: flex; justify-content: center; align-items: center; cursor: zoom-out;
}
#lightbox-img {
    max-width: 90%; max-height: 90%; border-radius: 16px;
    box-shadow: 0 0 50px rgba(255,255,255,0.15);
    animation: zoomIn 0.3s ease;
}
@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ==================================
   超級百科 (Encyclopedia)
================================== */
.encyclopedia-grid {
    display: grid; grid-template-columns: 1fr 2.5fr; gap: 30px;
}
@media (max-width: 900px) { .encyclopedia-grid { grid-template-columns: 1fr; } }
.ency-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px); border-radius: var(--radius); padding: 35px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.ency-card h2 {
    font-size: 1.8rem; margin-bottom: 25px; border-bottom: 1px solid rgba(255,255,255,0.2); padding-bottom: 15px;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}
.ency-item { margin-bottom: 20px; line-height: 1.8; font-size: 1.1rem; }
.ency-item strong { color: #f0f0f0; }
.tag-container { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.ency-tag {
    background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px;
    font-size: 0.95rem; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ==================================
   模組 2-9 擴充樣式
================================== */

/* 2: 隨機桌布 */
.wp-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
    background: var(--glass-bg);
    padding: 30px;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group label {
    font-size: 0.9rem;
    opacity: 0.7;
    font-weight: 600;
    text-transform: uppercase;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.template-item {
    aspect-ratio: 1;
    background: rgba(255,255,255,0.1);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    padding: 10px;
    transition: 0.3s;
}

.template-item:hover {
    background: rgba(255,255,255,0.2);
}

.template-item.active {
    border-color: #fff;
    background: rgba(255,255,255,0.3);
}

.ratio-toggle {
    display: flex;
    gap: 10px;
}

.ratio-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: #fff;
    cursor: pointer;
    transition: 0.3s;
}

.ratio-btn.active {
    background: #fff;
    color: #000;
}

/* 3: 心情看板 */
.moodboard { display: flex; flex-wrap: wrap; justify-content: center; position: relative; height: 65vh; align-items: center; }
.polaroid { background: white; padding: 10px 10px 40px 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); position: absolute; border: 1px solid #ccc; transition: transform 0.3s; cursor: pointer; }
.polaroid:hover { z-index: 10 !important; transform: scale(1.1) !important; }
.polaroid img { width: 250px; display: block; border: 1px solid #eee; }

/* 4: 每日金句 */
.quote-card { background: var(--glass-bg); backdrop-filter: blur(15px); padding: 60px; border-radius: var(--radius); text-align: center; border: 1px solid var(--glass-border); box-shadow: 0 15px 40px rgba(0,0,0,0.5); margin: 50px auto; max-width: 800px; display: flex; flex-direction: column; align-items: center; gap: 30px; }
.quote-card p { font-size: 2.2rem; font-weight: 600; font-style: italic; opacity: 0.95; text-shadow: 0 4px 10px rgba(0,0,0,0.8); line-height: 1.5; }

/* 5: 里程碑時間軸 */
.timeline { border-left: 3px solid rgba(255,255,255,0.3); margin-left: 20px; padding-left: 30px; position: relative; margin-top: 20px; }
.timeline-item { margin-bottom: 40px; position: relative; background: var(--glass-bg); padding: 25px; border-radius: var(--radius); backdrop-filter: blur(10px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); border: 1px solid var(--glass-border); font-size: 1.1rem; line-height: 1.6; }
.timeline-item::before { content: ''; position: absolute; left: -40px; top: 25px; width: 16px; height: 16px; background: white; border-radius: 50%; box-shadow: 0 0 10px white; }

/* 6: 照片拼圖 */
.puzzle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; width: min(80vw, 550px); height: min(80vw, 550px); margin: 0 auto; background: var(--glass-border); border: 4px solid var(--glass-bg); border-radius: 8px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.puzzle-piece { background-size: min(80vw, 550px) min(80vw, 550px); background-repeat: no-repeat; transition: opacity 0.3s, transform 0.3s; cursor: crosshair; }
.puzzle-piece:hover { opacity: 0.6; transform: scale(0.92); border-radius: 8px; }

/* 7: 投影片 */
.slideshow-view { width: 100%; height: 75vh; border-radius: var(--radius); background-size: contain; background-repeat: no-repeat; background-position: center; transition: background-image 1s ease-in-out; background-color: rgba(0,0,0,0.6); box-shadow: 0 10px 30px rgba(0,0,0,0.4); border: 1px solid var(--glass-border); }

/* 8: 色調濾鏡 */
.filter-view { display: flex; flex-direction: column; align-items: center; gap: 25px; }
.filter-img { max-width: 100%; max-height: 55vh; border-radius: var(--radius); transition: filter 0.5s ease; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.filter-controls { display: flex; gap: 15px; flex-wrap: wrap; justify-content: center; }

/* 9: 專屬倒數 */
.countdown-clock { font-size: clamp(3rem, 8vw, 7rem); font-weight: 800; text-align: center; letter-spacing: 5px; text-shadow: 0 5px 20px rgba(0,0,0,0.8); background: var(--glass-bg); backdrop-filter: blur(20px); padding: 40px; border-radius: var(--radius); margin: 50px auto; border: 1px solid var(--glass-border); box-shadow: 0 10px 40px rgba(0,0,0,0.4); display: flex; justify-content: center; gap: 20px; }
.countdown-block { display: flex; flex-direction: column; align-items: center; }
.countdown-label { font-size: 1.2rem; font-weight: 400; opacity: 0.8; letter-spacing: 2px; margin-top: 10px; }
