/* =========================================
   1. 全局變數 & 基礎設定
   ========================================= */
:root {
    --bg-color: #000000;
    --sidebar-bg: #000000;
    --text-main: #ffffff;
    --text-muted: #888888;
    --accent-purple: #c084fc;
    --gradient-btn: linear-gradient(90deg, #a855f7, #ec4899);
    --sidebar-width: 260px;
    --mobile-header-height: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    display: flex;
    min-height: 100vh;
}

html {
    overflow-y: scroll; /* 強制永遠顯示右側捲軸軌道，避免內容載入時寬度發生變化 */
}

/* =========================================
   2. 左側導覽列 (Sidebar)
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-right: 1px solid #222;
    
    /* 關鍵修改：確保高度不超過視窗，並允許捲動 */
    position: fixed;
    height: 100vh;      /* 佔滿視窗高度 (100% Viewport Height) */
    left: 0;
    top: 0;
    z-index: 1000;
    
    overflow-y: auto;   /* 關鍵：內容超出高度時顯示捲軸 */
    
    transition: transform 0.3s ease;
    
    /* 隱藏捲軸樣式 (Chrome/Safari/Edge) - 讓介面更乾淨 */
    scrollbar-width: none;  /* Firefox */
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
    font-size: 1.5rem;
    font-weight: bold;
}
.logo-img { height: 30px; }

.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: 0.3s;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.nav-item img, .wallet-header img, .wallet-actions .btn-wallet img, .user-menu-item img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: invert(1) brightness(0.6);
    transition: 0.3s;
}

.nav-item:hover img, .nav-item.active img, .wallet-actions .btn-wallet:hover img, .user-menu-item:hover img {
    filter: invert(1) brightness(1);
}

/* 錢包 & Footer */
.wallet-card {
    background-color: #1a1a1a;
    padding: 15px;
    border-radius: 15px;
    margin-top: auto;
    margin-bottom: 20px;
}
.wallet-header { display: flex; gap: 8px; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; }
.wallet-amount { font-size: 1.5rem; font-weight: bold; margin-bottom: 10px; }
.wallet-actions { display: flex; flex-direction: column; gap: 8px; }

.btn-wallet {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.2s;
}
.btn-topup { background: var(--gradient-btn); color: white; border: none; }
.btn-history { background: #333; color: white; }

/* 語言切換 */
.lang-container { margin-top: 20px; padding: 0 10px; position: relative; }
.lang-label { font-size: 0.75rem; color: #666; margin-bottom: 5px; padding-left: 5px; }
.current-lang-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: 10px 15px; background-color: #1a1a1a; border: 1px solid #333;
    border-radius: 12px; color: #fff; cursor: pointer; font-size: 0.9rem; transition: 0.3s;
}
.current-lang-btn:hover { border-color: #666; background-color: #222; }
.current-lang-btn.active { border-color: #c084fc; background-color: rgba(192, 132, 252, 0.1); }
.arrow-icon { font-size: 0.7rem; color: #888; transition: transform 0.3s; }
.current-lang-btn.active .arrow-icon { transform: rotate(180deg); }

.lang-dropdown-list {
    display: none; position: absolute; bottom: 100%; left: 0; width: 100%;
    margin-bottom: 8px; background-color: #111; border: 1px solid #333;
    border-radius: 12px; overflow: hidden; z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); animation: fadeInUp 0.2s ease-in-out;
}
.lang-item { display: flex; align-items: center; gap: 10px; padding: 10px 15px; color: #aaa; text-decoration: none; font-size: 0.9rem; transition: 0.2s; }
.lang-item:hover { background-color: #333; color: white; }
.flag-icon { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.user-footer { display: flex; align-items: center; gap: 10px; padding-top: 15px; border-top: 1px solid #333; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background-color: #555; }
.user-info { font-size: 0.9rem; }

/* 用戶選單 (User Menu Dropdown) */
.user-menu-container { position: relative; padding: 0; border-top: none; margin-top: 10px; }
.user-menu-trigger {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: 15px; background: transparent; border: none; border-top: 1px solid #333;
    color: var(--text-main); cursor: pointer; transition: 0.3s; border-radius: 0;
}
.user-menu-trigger:hover, .user-menu-trigger.active { background-color: rgba(255, 255, 255, 0.05); }
.user-trigger-left { display: flex; align-items: center; gap: 12px; }
.user-info { font-weight: 600; font-size: 0.95rem; }
.user-menu-trigger.active .user-arrow { transform: rotate(180deg); }
.user-dropdown-list {
    display: none; position: absolute; bottom: 100%; left: 0; width: 100%;
    margin-bottom: 10px; background-color: #111; border: 1px solid #333;
    border-radius: 12px; overflow: hidden; z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.5); animation: fadeInUp 0.2s ease-in-out;
}
.user-menu-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 15px;
    color: var(--text-muted); text-decoration: none; font-size: 0.95rem; transition: 0.2s;
}
.user-menu-item:hover { background-color: rgba(255, 255, 255, 0.1); color: var(--text-main); }

/* =========================================
   3. 手機版頂部導覽列 (Mobile Header)
   ========================================= */
.mobile-header {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: var(--mobile-header-height);
    background-color: rgba(0, 0, 0, 0.9); backdrop-filter: blur(10px);
    border-bottom: 1px solid #222; z-index: 900; align-items: center;
    padding: 0 20px; justify-content: space-between;
}
.mobile-logo {
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    
    /* 新增 Flex 排版讓圖片跟文字並排 */
    display: flex;
    align-items: center;
    gap: 10px; /* 圖片跟文字的間距 */
}
.mobile-logo img {
    height: 30px; /* 設定圖片高度，隨意調整 */
    width: auto;
    border-radius: 5px; /* 如果想要圓角可加這行 */
    object-fit: contain;
}
.hamburger-btn {
    background: none; border: none; cursor: pointer; display: flex; flex-direction: column;
    gap: 5px; width: 30px; height: 30px; justify-content: center;
}
.hamburger-btn span { display: block; width: 100%; height: 2px; background-color: white; border-radius: 2px; }
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 950; backdrop-filter: blur(2px);
    opacity: 0; transition: opacity 0.3s;
}

/* =========================================
   4. 右側主內容 (Main Content)
   ========================================= */
.main-content {
    margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column;
    min-height: 100vh; transition: margin-left 0.3s;
}
.content-wrapper { padding: 40px 60px; flex: 1; }
.alert-container { padding: 20px; }
.alert { color: #ff4444; background: rgba(255,0,0,0.1); padding: 10px; border-radius: 5px; }

/* Hero */
.hero-section { text-align: center; margin-bottom: 60px; margin-top: 40px; }
.hero-title { font-size: 4rem; font-weight: bold; margin-bottom: 10px; line-height: 1.2; }
.highlight-x { color: #ff66c4; }
.gradient-text { background: linear-gradient(90deg, #a855f7, #ff66c4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-buttons { display: flex; justify-content: center; gap: 20px; margin-top: 30px; }
.hero-btn { padding: 12px 30px; border-radius: 30px; text-decoration: none; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.btn-white { background: white; color: black; }
.btn-gradient { background: var(--gradient-btn); color: white; }
.hero-subtitle { margin-top: 20px; color: var(--text-muted); font-size: 0.9rem; letter-spacing: 2px; }

/* Grid (首頁用) */
.gallery-grid { column-count: 4; column-gap: 16px; width: 100%; max-width: 1200px; margin: 0 auto; }
.grid-item { background-color: #333; border-radius: 16px; margin-bottom: 16px; break-inside: avoid; width: 100%; }
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-tall { aspect-ratio: 9 / 16; }
.grid-item img, .grid-item video { width: 100%; height: 100%; object-fit: cover; }

/* =========================================
   5. Footer
   ========================================= */
.site-footer { width: 100%; background-color: #111; border-top: 1px solid #222; padding: 0; }
.footer-content { width: 100%; max-width: 1200px; margin: 0 auto; padding: 60px 20px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 40px; box-sizing: border-box; }
.footer-left { display: flex; flex-direction: column; gap: 15px; }
.footer-brand-row { display: flex; align-items: center; gap: 20px; }
.footer-logo { font-size: 2rem; color: white; font-weight: bold; line-height: 1; }
.footer-copyright { font-size: 0.85rem; color: #666; letter-spacing: 0.5px; }
.social-icons { display: flex; gap: 12px; }
.social-btn { display: flex; justify-content: center; align-items: center; width: 36px; height: 36px; background-color: #333; border-radius: 50%; transition: 0.3s; padding: 0; margin: 0; line-height: 1; text-decoration: none; }
.social-btn img { display: block; width: 20px; height: 20px; object-fit: contain; filter: invert(1); }
.social-btn:hover { background-color: #c084fc; transform: translateY(-2px); }
.footer-links { display: flex; flex-direction: row; gap: 80px; }
.footer-col { display: flex; flex-direction: column; gap: 15px; min-width: 100px; }
.footer-col strong { color: #999; font-size: 1rem; font-weight: normal; margin-bottom: 5px; }
.footer-col a { color: #ccc; text-decoration: none; font-size: 0.95rem; transition: 0.3s; }
.footer-col a:hover { color: white; text-decoration: underline; }

/* =========================================
   6. RWD 響應式設計
   ========================================= */
@media (max-width: 768px) {
    .mobile-header { display: flex; }
    .sidebar { transform: translateX(-100%); width: 280px; box-shadow: 4px 0 15px rgba(0,0,0,0.5); }
    .sidebar.active { transform: translateX(0); }
    .sidebar-overlay.active { display: block; opacity: 1; }
    .sidebar .logo-area { display: none; } 
    .main-content { margin-left: 0; padding-top: var(--mobile-header-height); }
    .content-wrapper { padding: 30px 20px; }
    .hero-title { font-size: 2.5rem; }
    .hero-buttons { flex-direction: column; width: 100%; }
    .hero-btn { justify-content: center; width: 100%; }
    .gallery-grid { column-count: 2; column-gap: 10px; }
    .grid-item { margin-bottom: 10px; border-radius: 10px; }
    .footer-content { flex-direction: column; gap: 40px; padding: 40px 20px; }
    .footer-links { width: 100%; justify-content: space-between; gap: 0; }
    .modal-container { flex-direction: column; height: auto; max-height: 95vh; width: 90%; }
    .modal-left { display: none; }
    .modal-right { padding: 40px 20px; }
}

/* =========================================
   7. 登入/註冊 彈跳視窗 (Login/Register Modal)
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8); backdrop-filter: blur(5px);
    z-index: 3000 !important; /* 最高層級 */
    display: none; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s ease;
}
.modal-overlay.active { display: flex; opacity: 1; }
.modal-container {
    background-color: #000; width: 900px; max-width: 95%; height: 600px; max-height: 90vh;
    border-radius: 20px; border: 1px solid #333; display: flex; overflow: hidden;
    position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.5); animation: zoomIn 0.3s ease;
}
@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-left { flex: 1; background-color: #222; position: relative; }
.modal-left img { width: 100%; height: 100%; object-fit: cover; }
.modal-right { flex: 1; padding: 60px 50px; display: flex; flex-direction: column; justify-content: center; background-color: #0a0a0a; }
.modal-title { font-size: 2rem; font-weight: bold; color: white; margin-bottom: 30px; }
.input-group { position: relative; margin-bottom: 20px; }
.input-group input {
    width: 100%; padding: 15px 15px 15px 45px; background-color: #1f1f1f;
    border: 1px solid #333; border-radius: 12px; color: white; font-size: 1rem;
    outline: none; transition: 0.3s;
}
.input-group input:focus { border-color: var(--accent-purple); background-color: #2a2a2a; }
.input-icon {
    position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; object-fit: contain; filter: invert(0.6);
}
.form-actions { margin-bottom: 20px; }
.forgot-link { color: #888; font-size: 0.9rem; text-decoration: none; }
.forgot-link:hover { color: white; }
.btn-submit {
    width: 100%; padding: 15px; border: none; border-radius: 12px;
    background: var(--gradient-btn); color: white; font-size: 1.1rem;
    font-weight: bold; cursor: pointer; margin-bottom: 30px; transition: opacity 0.3s;
}
.btn-submit:hover { opacity: 0.9; }
.divider { text-align: center; position: relative; margin-bottom: 30px; color: #666; font-size: 0.9rem; }
.divider::before, .divider::after {
    content: ""; position: absolute; top: 50%; width: 30%; height: 1px; background-color: #333;
}
.divider::before { left: 0; } .divider::after { right: 0; }
.social-login-btns { display: flex; gap: 20px; justify-content: center; margin-bottom: 30px; }
.btn-social {
    flex: 1; background-color: white; border-radius: 10px; padding: 12px;
    display: flex; justify-content: center; align-items: center; transition: 0.2s;
}
.btn-social img { height: 24px; width: auto; object-fit: contain; }
.btn-social img[alt="X"] { filter: none; }
.btn-social:hover { transform: translateY(-2px); }
.modal-footer { text-align: center; color: #888; font-size: 0.95rem; }
.modal-footer a { color: #ff66c4; text-decoration: none; font-weight: bold; margin-left: 5px; }
.modal-footer a:hover { text-decoration: underline; }

/* 登入/註冊切換樣式 */
.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 30px;
}
.auth-switch {
    font-size: 0.95rem;
    color: #666;
}
.auth-switch span {
    cursor: pointer;
    transition: 0.2s;
}
.auth-switch span.active {
    color: #ff66c4; /* Pink */
    font-weight: bold;
    border-bottom: 2px solid #ff66c4;
    padding-bottom: 2px;
}
.auth-switch span:hover:not(.active) {
    color: white;
}
.divider-small {
    margin: 0 8px;
    color: #333;
}
.terms-text {
    font-size: 0.8rem;
    color: #666;
}
.btn-register-color {
    background: linear-gradient(90deg, #ff66c4, #a855f7); /* 反向漸層區分 */
}

/* =========================================
   8. 圖片生成頁面 (Gen UI)
   ========================================= */
.gen-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 40px 120px 40px; color: #fff; box-sizing: border-box; }
.gen-textarea { width: 100%; max-width: 100%; background: #111; border: 1px solid #333; border-radius: 16px; color: white; padding: 20px; font-size: 1rem; line-height: 1.6; resize: vertical; box-sizing: border-box; display: block; }
.gen-textarea:focus { outline: none; border-color: var(--accent-purple); }
.gen-tabs-wrapper { display: flex; justify-content: center; margin-bottom: 40px; }
.gen-tabs { background: #1a1a1a; padding: 5px; border-radius: 50px; display: inline-flex; gap: 0; border: 1px solid #333; }
.gen-tab { background: transparent; border: none; color: #888; padding: 10px 30px; border-radius: 40px; cursor: pointer; font-size: 0.95rem; font-weight: 500; transition: 0.3s; }
.gen-tab.active { background: var(--gradient-btn); color: white; box-shadow: 0 2px 10px rgba(192, 132, 252, 0.3); }
.gen-header { margin-bottom: 40px; }
.gen-header h1 { font-size: 2rem; font-weight: bold; margin-bottom: 10px; color: #fff; }
.gen-header p { color: #888; font-size: 0.9rem; letter-spacing: 1px; }
.control-section { width: 100%; margin-bottom: 30px; background: transparent; padding: 10px 0; }
.section-title { font-size: 1rem; font-weight: bold; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; color: #eee; }
.dot-indicator { width: 6px; height: 6px; background-color: #ff66c4; border-radius: 50%; display: inline-block; box-shadow: 0 0 5px #ff66c4; }
.control-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.value-display { font-size: 0.9rem; color: #fff; }
.style-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.style-card { position: relative; aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; cursor: pointer; border: 2px solid transparent; transition: 0.2s; background: #222; }
.style-card img { width: 100%; height: 100%; object-fit: cover; opacity: 0.6; transition: 0.3s; }
.style-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; z-index: 2; }
.style-name { color: white; font-size: 0.85rem; font-weight: bold; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.style-card.active { border-color: #ff66c4; box-shadow: 0 0 15px rgba(255, 102, 196, 0.3); }
.style-card.active img { opacity: 0.4; }
.custom-slider { -webkit-appearance: none; width: 100%; height: 6px; background: #333; border-radius: 5px; outline: none; background-image: linear-gradient(#ff66c4, #ff66c4); background-repeat: no-repeat; cursor: pointer; }
.custom-slider::-webkit-slider-thumb { -webkit-appearance: none; height: 18px; width: 18px; border-radius: 50%; background: #ff66c4; cursor: pointer; box-shadow: 0 0 10px rgba(255, 102, 196, 0.5); border: 2px solid #fff; margin-top: 0px; }
.slider-wrapper { display: flex; align-items: center; gap: 15px; }
.slider-label { font-size: 0.8rem; color: #666; }
.accordions-wrapper { border: 1px solid #333; border-radius: 20px; background-color: #050505; padding: 10px; }
.accordion-group { border-bottom: 1px solid #222; }
.accordion-group:last-child { border-bottom: none; }
.accordion-header { padding: 18px 10px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: 0.2s; }
.accordion-header:hover { background-color: #111; border-radius: 10px; }
.acc-title-area { display: flex; align-items: center; gap: 15px; font-size: 0.95rem; font-weight: 500; flex-wrap: wrap; }
.acc-arrow { color: #666; font-size: 0.8rem; transition: transform 0.3s; }
.selected-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-chip { display: inline-block; font-size: 0.75rem; color: #ff66c4; border: 1px solid #ff66c4; padding: 2px 10px; border-radius: 20px; background-color: rgba(255, 102, 196, 0.1); white-space: nowrap; transition: 0.2s; }
.tag-chip:hover { background-color: rgba(255, 102, 196, 0.2); }
.accordion-body { padding: 10px; display: none; }
.tags-wrapper { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-btn { background: #222; border: 1px solid #333; color: #aaa; padding: 8px 20px; border-radius: 30px; cursor: pointer; font-size: 0.9rem; transition: 0.2s; min-width: 60px; text-align: center; }
.tag-btn:hover { background: #333; color: white; }
.tag-btn.active { background: linear-gradient(135deg, #c084fc, #ff66c4); color: white; border-color: transparent; font-weight: bold; box-shadow: 0 2px 8px rgba(192, 132, 252, 0.4); }
.ratio-options { display: flex; gap: 12px; }
.ratio-btn { flex: 1; background: #1a1a1a; border: 1px solid #333; color: #888; padding: 12px 0; border-radius: 12px; cursor: pointer; font-size: 0.9rem; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.ratio-btn:hover { background: #222; }
.ratio-btn.active { background: linear-gradient(135deg, #c084fc, #ff66c4); color: white; border-color: transparent; font-weight: bold; }
.big-gen-btn { width: 100%; padding: 18px; border-radius: 16px; background: var(--gradient-btn); border: none; color: white; font-size: 1.2rem; font-weight: bold; display: flex; justify-content: center; align-items: center; gap: 10px; cursor: pointer; margin-top: 40px; box-shadow: 0 5px 25px rgba(168, 85, 247, 0.4); transition: 0.3s; }
.big-gen-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(168, 85, 247, 0.6); filter: brightness(1.1); }
.bolt-icon { width: 20px; height: 24px; filter: brightness(0) invert(1); }
.gen-mode-content { display: none; }
.gen-mode-content.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 768px) { .style-grid { grid-template-columns: repeat(3, 1fr); } .ratio-options { flex-wrap: wrap; } .ratio-btn { min-width: 30%; } }

/* =========================================
   9. 全站共用元件 (Toggle, Loading, Modal)
   ========================================= */
.toggle-switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }
input:checked + .slider { background-color: #ff66c4; box-shadow: 0 0 10px rgba(255, 102, 196, 0.4); }
input:checked + .slider:before { transform: translateX(24px); }

/* Loading Overlay */
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.95); z-index: 9999; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.loading-overlay.active { opacity: 1; pointer-events: auto; }
.loading-content { text-align: center; position: relative; width: 200px; height: 200px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.spinner-loader { position: absolute; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0%, #a855f7 50%, #ff66c4 100%); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #fff calc(100% - 6px)); mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #fff calc(100% - 6px)); animation: spin 1s linear infinite; }
.spinner-loader::after { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 8px; height: 8px; border-radius: 50%; background: #ff66c4; box-shadow: 0 0 10px #ff66c4; }
.loading-percent { font-size: 2rem; font-weight: bold; background: linear-gradient(90deg, #a855f7, #ff66c4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 10px; z-index: 2; }
.loading-text { font-size: 1rem; color: white; font-weight: bold; z-index: 2; margin-top: 130px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Global Modal */
.modal-card { background: #111; border: 1px solid #333; padding: 30px; border-radius: 20px; text-align: center; width: 320px; max-width: 90%; box-shadow: 0 10px 40px rgba(0,0,0,0.8); transform: scale(0.8); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.active .modal-card { transform: scale(1); }
.modal-icon-wrapper { width: 60px; height: 60px; background: #222; border-radius: 50%; margin: 0 auto 20px; display: flex; justify-content: center; align-items: center; }
.modal-icon-wrapper img { width: 30px; height: 30px; object-fit: contain; display: block; }
.modal-title { font-size: 1.5rem; color: white; margin-bottom: 10px; font-weight: bold; }
.modal-desc { color: #aaa; font-size: 0.95rem; margin-bottom: 25px; line-height: 1.5; }
.modal-image-wrapper { width: 100%; margin-bottom: 20px; border-radius: 12px; overflow: hidden; border: 2px solid #333; background: #000; }
.modal-image-wrapper img { width: 100%; height: auto; max-height: 300px; object-fit: contain; display: block; }
.modal-actions { display: flex; gap: 10px; width: 100%; margin-top: 20px; }
.modal-btn { flex: 1; padding: 12px; border-radius: 10px; border: none; font-weight: bold; cursor: pointer; font-size: 0.95rem; transition: 0.2s; color: white; }
.btn-outline { background: transparent !important; border: 1px solid #555 !important; color: #aaa !important; }
.btn-outline:hover { border-color: #fff !important; color: #fff !important; background: rgba(255,255,255,0.1) !important; }
#modal-btn-primary { background: linear-gradient(90deg, #a855f7, #ec4899) !important; color: white !important; border: none !important; font-weight: bold; box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4); transition: 0.3s; }
#modal-btn-primary:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6); }
#modal-btn-secondary.btn-outline { background: transparent !important; border: 2px solid #c084fc !important; color: #c084fc !important; font-weight: bold; transition: 0.3s; }
#modal-btn-secondary.btn-outline:hover { background: rgba(192, 132, 252, 0.1) !important; color: #d8b4fe !important; border-color: #d8b4fe !important; transform: translateY(-2px); }

/* Modal Icon Colors */
.modal-icon-red { filter: invert(30%) sepia(96%) saturate(1637%) hue-rotate(336deg) brightness(92%) contrast(97%) !important; }
.modal-icon-green { filter: invert(65%) sepia(54%) saturate(464%) hue-rotate(90deg) brightness(92%) contrast(87%) !important; }
.modal-icon-gray { filter: invert(0.8) !important; }

/* =========================================
   10. Topup 儲值頁面
   ========================================= */
.topup-page-wrapper { max-width: 1100px; margin: 0 auto; padding: 40px 20px 120px 20px; text-align: center; color: white; }
.topup-header h1 { font-size: 2.8rem; margin-bottom: 15px; font-weight: bold; color: #fff; }
.topup-header p { color: #999; margin-bottom: 60px; letter-spacing: 2px; font-size: 0.95rem; }
.topup-content-grid { display: flex; justify-content: center; align-items: center; gap: 80px; margin-bottom: 80px; }
.plans-column { display: flex; flex-direction: column; gap: 25px; width: 520px; }
.plan-card { background: #0f0f0f; border: 1px solid #333; border-radius: 24px; padding: 0 40px; display: flex; align-items: center; cursor: pointer; position: relative; transition: 0.3s; height: 140px; }
.plan-card:hover { background: #1a1a1a; transform: translateY(-2px); border-color: #555; }
.plan-card.selected { border: 2px solid #a855f7; background-color: #161616; box-shadow: 0 0 30px rgba(168, 85, 247, 0.2); }
.badge-best { position: absolute; top: -12px; left: 20px; background: #a855f7; color: white; font-size: 0.75rem; font-weight: bold; padding: 4px 12px; border-radius: 12px; box-shadow: 0 4px 10px rgba(168, 85, 247, 0.4); }
.plan-vertical-divider { width: 1px; height: 60px; background-color: #333; margin: 0 30px; }
.plan-col-points { flex: 0 0 140px; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; }
.points-row { display: flex; align-items: center; gap: 8px; line-height: 1; }
.sparkle-icon { width: 28px; height: auto; filter: invert(58%) sepia(91%) saturate(2204%) hue-rotate(297deg) brightness(101%) contrast(101%); }
.plan-points { font-size: 3rem; font-weight: 800; color: #ff66c4; text-shadow: 0 0 20px rgba(255, 102, 196, 0.4); }
.plan-label { font-size: 0.85rem; color: #ddd; letter-spacing: 2px; font-weight: 600; margin-top: 6px; width: 100%; text-align: right; }
.plan-col-info { flex: 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; white-space: nowrap; }
.discount-tag { color: #ff66c4; font-size: 0.9rem; font-weight: 700; background: transparent; padding: 0; margin-bottom: 4px; }
.price-original { font-size: 1.1rem; color: #ffffff; text-decoration: line-through; }
.plan-col-price { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; }
.price-final-styled { display: flex; align-items: baseline; line-height: 1; color: white; font-weight: 800; }
.price-symbol { font-size: 2.8rem; margin-right: 2px; color: #fff; margin-top: 4px; }
.price-integer { font-size: 3.8rem; }
.price-decimal { font-size: 1.8rem; }
.features-column { text-align: left; }
.feature-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.feature-list li { font-size: 1.2rem; display: flex; align-items: center; gap: 18px; color: #eee; font-weight: 500; }
.check-icon { width: 24px; height: 24px; filter: invert(58%) sepia(91%) saturate(2204%) hue-rotate(297deg) brightness(101%) contrast(101%); }
.payment-methods-area { display: flex; flex-direction: column; gap: 25px; margin-bottom: 100px; max-width: 800px; margin-left: auto; margin-right: auto; }
.payment-row { display: flex; justify-content: center; gap: 25px; }
.pay-btn { flex: 1; max-width: 360px; background: linear-gradient(90deg, #a855f7, #ec4899); border: none; border-radius: 40px; padding: 0 20px; display: flex; justify-content: center; align-items: center; gap: 12px; cursor: pointer; transition: 0.3s; min-height: 80px; color: white; font-size: 1.2rem; font-weight: 600; box-shadow: 0 5px 20px rgba(168, 85, 247, 0.3); }
.pay-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(168, 85, 247, 0.6); filter: brightness(1.1); }
.pay-icon-apple, .pay-icon-google { height: 60px !important; width: auto; }
.card-icons-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0px; margin-left: 5px; line-height: 0; }
.card-icons-stack img { display: block; object-fit: contain; height: auto !important; max-height: 40px; }
.card-icons-stack img[alt="Visa"] { width: 30px !important; margin-bottom: -8px; }
.card-icons-stack img[alt="Mastercard"] { width: 42px !important; }
.crypto-icons { display: flex; gap: 10px; align-items: center; }
.crypto-icons img { height: 34px !important; }
.trust-footer { padding-top: 20px; max-width: 900px; margin: 0 auto; }
.secure-banner { border: 1px solid #333; border-radius: 30px; padding: 15px 40px; display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 40px; color: #ccc; font-size: 1.1rem; background: rgba(255,255,255,0.02); }
.shield-green { width: 24px; height: 24px; filter: invert(76%) sepia(34%) saturate(769%) hue-rotate(88deg) brightness(98%) contrast(92%); }
.bolt-color { filter: invert(76%) sepia(34%) saturate(769%) hue-rotate(88deg) brightness(98%) contrast(92%); }
.trust-features { display: flex; justify-content: space-between; gap: 20px; }
.trust-item { border: 1px solid #333; border-radius: 24px; padding: 25px 20px; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; background-color: #0f0f0f; transition: 0.3s; }
.trust-item:hover { border-color: #555; background-color: #141414; }
.trust-item img.small { width: 28px; height: 28px; margin-bottom: 5px; }
.trust-item h4 { color: #4ade80; margin-bottom: 0; font-size: 1.1rem; font-weight: 600; }
.trust-item p { color: #888; font-size: 0.9rem; margin: 0; line-height: 1.4; }
@media (max-width: 900px) {
    .topup-content-grid { flex-direction: column; gap: 50px; }
    .plans-column { width: 100%; }
    .payment-row { flex-direction: column; }
    .pay-btn { width: 100%; max-width: none; height: 80px; padding: 0 20px; }
    .trust-features { flex-direction: column; gap: 20px; }
}

/* =========================================
   11. My Library (我的檔案) 
   ========================================= */
.library-container { max-width: 1800px; margin: 0 auto; padding: 40px 10%; color: white; min-height: 80vh; width: 100%; box-sizing: border-box; }
.library-header h1 { font-size: 2.5rem; font-weight: bold; margin-bottom: 10px; }
.library-header p { color: #888; margin-bottom: 40px; letter-spacing: 1px; }

@media (max-width: 1400px) {
    .library-container {
        padding: 40px 5%; /* 改為 5% */
    }
}

/* 平板/手機版：改回固定間距，避免內容被壓太扁 */
@media (max-width: 768px) {
    .library-container {
        padding: 20px 20px; /* 手機版維持舒適的小間距 */
    }
    
    .library-grid {
        grid-template-columns: repeat(2, 1fr); /* 手機版強制兩欄 */
        gap: 10px;
    }
}

/* Tabs */
.library-tabs { display: inline-flex; align-items: center; gap: 15px; margin-bottom: 30px; background: #0a0a0a; padding: 6px 8px; border-radius: 60px; border: 1px solid #222; }
.tabs-group-bordered { display: flex; align-items: center; gap: 2px; border: 1px solid #c084fc; border-radius: 50px; padding: 4px; background: rgba(192, 132, 252, 0.05); }
.lib-tab { background: transparent; border: none; color: #888; padding: 10px 24px; border-radius: 40px; cursor: pointer; font-size: 0.95rem; transition: 0.3s; display: flex; align-items: center; gap: 8px; white-space: nowrap; position: relative; }
.lib-tab.active { background: var(--gradient-btn); color: white; font-weight: bold; box-shadow: 0 2px 10px rgba(192, 132, 252, 0.3); }
.lib-tab:hover:not(.active) { color: white; background: rgba(255,255,255,0.05); }
.lib-tab.disabled { opacity: 0.5; cursor: not-allowed; }

/* Tooltip */
.tooltip-container { position: relative; display: flex; align-items: center; justify-content: center; margin-left: 2px; }
.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background-color: rgba(255, 255, 255, 0.2); color: #ccc; font-size: 10px; font-weight: bold; cursor: help; transition: 0.2s; }
.lib-tab:hover .help-icon { background-color: rgba(255, 255, 255, 0.4); color: white; }
.tooltip-text { visibility: hidden; width: max-content; max-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 8px; padding: 8px 12px; position: absolute; z-index: 10; bottom: 140%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s; font-size: 0.75rem; font-weight: normal; box-shadow: 0 4px 10px rgba(0,0,0,0.5); border: 1px solid #555; pointer-events: none; white-space: normal; line-height: 1.4; }
.tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #333 transparent transparent transparent; }
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

/* Library Grid */
.library-grid { display: grid; gap: 20px; width: 100%; grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1600px) { .library-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1300px) { .library-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 992px) { .library-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .library-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* Card */
.lib-card { position: relative; border-radius: 20px; overflow: hidden; background-color: #222; aspect-ratio: 1/1; cursor: pointer; transition: transform 0.3s; border: 1px solid transparent; width: 100% !important; min-width: 0 !important; max-width: 100% !important; }
.lib-card:hover { transform: translateY(-4px); border-color: #444; }
.lib-img-wrapper { width: 100%; height: 100%; position: relative; }
.lib-img-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }
.lib-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to top, rgba(0,0,0,0.6), transparent); opacity: 0; transition: 0.3s; }
.lib-card:hover .lib-overlay { opacity: 1; }
.lib-card script { display: none !important; position: absolute !important; width: 0 !important; height: 0 !important; }
.lib-card * { max-width: 100% !important; white-space: normal !important; word-break: break-all !important; overflow-wrap: anywhere !important; }

/* Status Pill */
.lib-status-pill { position: absolute; bottom: 15px; left: 15px; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); padding: 6px 12px; border-radius: 20px; display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: white; border: 1px solid rgba(255,255,255,0.1); z-index: 2; }
.pill-icon { width: 12px; height: 12px; filter: invert(1); }
.lib-status-pill.public { background: rgba(255, 102, 196, 0.1); border-color: #ff66c4; color: white; }
.lib-status-pill.public .pill-icon { filter: invert(1); }

/* Menu Btn */
.lib-menu-btn { position: absolute; top: 15px; right: 15px; background: transparent; border: none; display: flex; flex-direction: column; gap: 3px; cursor: pointer; z-index: 2; padding: 5px; }
.dot { width: 4px; height: 4px; background-color: white; border-radius: 50%; box-shadow: 0 0 2px rgba(0,0,0,0.5); }

/* Empty State */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: #666; text-align: center; width: 100%; min-height: 400px; }
.btn-create { margin-top: 20px; padding: 12px 30px; background: var(--gradient-btn); color: white; text-decoration: none; border-radius: 30px; font-weight: bold; display: inline-block; }

/* =========================================
   12. 詳細資訊 Modal 樣式
   ========================================= */
.detail-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px); z-index: 2000 !important; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: 0.3s; }
.detail-modal-overlay.active { opacity: 1; pointer-events: auto; }
.detail-modal-content { width: 800px; max-width: 95vw; height: 85vh; background: #111; border-radius: 24px; border: 1px solid #333; position: relative; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.8); display: flex; flex-direction: column; }
.modal-close-btn { position: absolute; top: 20px; right: 20px; width: 32px; height: 32px; background: #000; border: none; border-radius: 50%; color: white; font-size: 1.2rem; line-height: 1; cursor: pointer; z-index: 20; display: flex; align-items: center; justify-content: center; transition: 0.2s; opacity: 0.8; }
.modal-close-btn:hover { opacity: 1; transform: scale(1.1); background: #222; }
.dm-layout { display: flex; flex-direction: column; height: 100%; overflow-y: auto; }
.dm-image-section { width: 100%; height: 55vh; min-height: 300px; background: #000; position: relative; display: flex; justify-content: center; align-items: center; }
.dm-image-container { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
.dm-image-container img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dm-stats-pill-top { position: absolute; top: 20px; right: 65px; background: #000; padding: 4px 12px; border-radius: 20px; display: flex; align-items: center; gap: 10px; border: none; font-size: 0.85rem; color: white; z-index: 10; height: 32px; opacity: 0.9; }
.dm-stats-pill-top .divider { color: #333; font-size: 0.8rem; margin: 0 2px; }
.pill-icon-small { width: 14px; height: 14px; filter: invert(1); display: block; }
.heart-icon { font-size: 0.9rem; line-height: 1; }
.heart-icon-btn { cursor: pointer; transition: transform 0.1s; display: inline-block; }
.heart-icon-btn:active { transform: scale(1.2); }
.dm-info-section { padding: 25px 30px; background: #111; flex: 1; display: flex; flex-direction: column; gap: 20px; }
.dm-meta-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.dm-meta-left { display: flex; gap: 10px; align-items: center; }
.dm-tag { font-size: 0.85rem; color: #aaa; background: #222; padding: 4px 10px; border-radius: 6px; border: 1px solid #333; display: flex; align-items: center; gap: 5px; }
.icon-ratio-box { display: inline-block; width: 14px; height: 10px; border: 1.5px solid #aaa; border-radius: 2px; }
.dm-meta-right { display: flex; align-items: center; gap: 12px; }
.dm-vis-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; cursor: pointer; transition: 0.2s; border: 1px solid transparent; }
.dm-vis-btn.public { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border-color: rgba(46, 204, 113, 0.3); }
.dm-vis-btn.public:hover { background: rgba(46, 204, 113, 0.25); }
.dm-vis-btn.private { background: rgba(255, 255, 255, 0.1); color: #aaa; border-color: rgba(255, 255, 255, 0.2); }
.dm-vis-btn.private:hover { background: rgba(255, 255, 255, 0.2); color: white; }
.dm-share-icon-btn { background: transparent; border: none; cursor: pointer; padding: 5px; transition: 0.2s; display: flex; align-items: center; }
.dm-share-icon-btn img { width: 20px; height: 20px; filter: invert(0.6); }
.dm-share-icon-btn:hover img { filter: invert(1); transform: scale(1.1); }
.dm-prompt-section { flex: 1; }
.dm-section-label { font-size: 0.9rem; color: #ff66c4; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; font-weight: bold; }
.dm-prompt-box { background: #161616; border: 1px solid #333; padding: 15px; border-radius: 12px; font-size: 0.9rem; color: #ccc; line-height: 1.6; max-height: 120px; overflow-y: auto; cursor: pointer; position: relative; transition: 0.2s; }
.dm-prompt-box:hover { border-color: #555; background: #1a1a1a; }
.copy-hint { position: absolute; bottom: 10px; right: 15px; font-size: 0.75rem; color: #666; }
.dm-actions-grid-simple {
    display: grid;
    grid-template-columns: 1fr auto; 
    gap: 12px;
    margin-top: 25px;
    height: 50px;
    width: 100%;
}
.btn-action { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 0 20px; height: 100%; border-radius: 12px; font-weight: bold; font-size: 0.95rem; cursor: pointer; border: none; transition: 0.2s; text-decoration: none; white-space: nowrap; }
.btn-download { flex: 1; background: var(--gradient-btn); color: white; box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3); }
.btn-download:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn-generate-similar { background: linear-gradient(90deg, #a855f7, #ec4899); color: white; border: none; }
.btn-generate-similar:hover { opacity: 0.9; box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3); }
.btn-generate-similar .btn-icon { filter: brightness(0) invert(1); width: 16px; }
.btn-delete-simple { width: 60px; background: rgba(255, 59, 48, 0.15); border: 1px solid #ff3b30; display: flex; justify-content: center; align-items: center; border-radius: 12px; cursor: pointer; transition: all 0.2s ease; padding: 0; }
.btn-delete-simple:hover { background: #ff3b30; box-shadow: 0 0 15px rgba(255, 59, 48, 0.5); transform: translateY(-2px); }
.btn-delete-simple img { width: 20px !important; height: 20px !important; filter: invert(33%) sepia(63%) saturate(4320%) hue-rotate(344deg) brightness(102%) contrast(105%); transition: 0.2s; }
.btn-delete-simple:hover img { filter: invert(1) brightness(2); }
.btn-icon { width: 18px; height: 18px; margin-right: 6px; filter: brightness(0) invert(1); }
/* RWD 手機版：詳細視窗全螢幕化 */
@media (max-width: 768px) { 
    /* 1. 外層遮罩：改回置中，並增加一點 padding 防止貼邊 */
    .detail-modal-overlay {
        align-items: center !important; /* 垂直置中 */
        justify-content: center !important;
        padding: 20px; /* 畫面邊緣留白 */
    }

    /* 2. 內容卡片：改為懸浮卡片樣式，而非滿版 */
    .detail-modal-content { 
        width: 100% !important;
        max-width: 450px !important; /* 限制最大寬度，避免在平板太寬 */
        height: auto !important;     /* 高度由內容決定 */
        max-height: 85vh !important; /* 最大高度不超過螢幕 85% */
        border-radius: 20px !important; /* 恢復圓角 */
        border: 1px solid #333 !important; /* 恢復邊框 */
        display: flex;
        flex-direction: column;
        background: #111;
        overflow: hidden; /* 確保圓角不被切掉 */
        box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    } 

    /* 3. 圖片區域：固定一個適合手機的高度比例 */
    .dm-image-section { 
        width: 100%;
        height: 40vh; /* 佔據螢幕高度的 40% */
        min-height: 250px; /* 最小高度防止太扁 */
        flex-shrink: 0; 
        background-color: #000;
        border-bottom: 1px solid #222;
    } 

    /* 4. 資訊區域：自適應剩餘空間，內容過多可滑動 */
    .dm-info-section {
        flex: 1;
        padding: 20px; /* 維持舒適的內距 */
        overflow-y: auto; /* 只有這塊區域會捲動 */
        display: flex;
        flex-direction: column;
        gap: 15px; /* 縮小一點間距適應手機 */
    }

    /* 5. 提示詞框框：限制高度，避免佔據太多空間 */
    .dm-prompt-box {
        max-height: 100px; /* 手機版稍微縮小一點 */
    }

    /* 6. 關閉按鈕：調整位置，確保不會擋到圖片 */
    .modal-close-btn {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
        background: rgba(0, 0, 0, 0.5); /* 半透明黑底，確保在淺色圖上也看得到 */
        backdrop-filter: blur(4px);
    }

    /* 7. 下載與刪除按鈕區塊 */
    .dm-actions-grid-simple {
        margin-top: 10px;
        height: 45px; /* 按鈕稍微改矮一點點，節省空間 */
    }
}

/* Toast Notification */
.toast-notification { position: fixed; top: 20px; right: 20px; background-color: rgba(0, 0, 0, 0.8); border: 1px solid #2ecc71; color: #2ecc71; padding: 12px 24px; border-radius: 12px; font-size: 0.95rem; font-weight: bold; display: flex; align-items: center; gap: 8px; z-index: 9999; opacity: 0; transform: translateY(-20px); transition: all 0.3s ease-out; pointer-events: none; }
.toast-notification.show { opacity: 1; transform: translateY(0); }
.toast-icon { width: 16px; height: 16px; filter: invert(66%) sepia(61%) saturate(467%) hue-rotate(95deg) brightness(89%) contrast(85%); }

/* =========================================
   13. Explore Page (探索頁面)
   ========================================= */
.explore-container {
    /* 放寬最大寬度，改由 padding 控制視覺邊界 */
    max-width: 100%; 
    margin: 0;
    
    /* [重點修改] 上下 40px，左右 10% (寬螢幕時會有大約 2/3 張圖寬的留白) */
    padding: 40px 10%; 
    
    color: white;
    box-sizing: border-box;
}
@media (max-width: 1400px) {
    .explore-container {
        padding: 40px 5%; 
    }
}

/* 平板/手機版：改回固定間距 20px，確保內容最大化 */
@media (max-width: 768px) {
    .explore-container {
        padding: 20px 20px; 
    }
    
    /* 確保手機版工具列排版正常 */
    .explore-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}
.explore-header h1 { font-size: 2.5rem; font-weight: bold; margin-bottom: 10px; }
.explore-header p { color: #888; margin-bottom: 40px; letter-spacing: 1px; }
.explore-toolbar { display: flex; gap: 15px; margin-bottom: 40px; align-items: center; }
.search-bar-wrapper { flex: 1; background: #111; border: 1px solid #333; border-radius: 50px; display: flex; align-items: center; padding: 10px 20px; transition: 0.3s; }
.search-bar-wrapper:focus-within { border-color: #c084fc; box-shadow: 0 0 10px rgba(192, 132, 252, 0.2); }
.search-icon { width: 18px; height: 18px; margin-right: 10px; filter: invert(0.5); }
.search-input { background: transparent; border: none; color: white; font-size: 1rem; width: 100%; outline: none; }
.filter-btn { display: flex; align-items: center; gap: 8px; background: #111; border: 1px solid #333; color: #ccc; padding: 12px 24px; border-radius: 50px; cursor: pointer; font-size: 0.95rem; transition: 0.3s; white-space: nowrap; }
.filter-btn:hover { background: #222; color: white; border-color: #555; }
.filter-icon { width: 16px; height: 16px; filter: invert(0.8); }
.explore-masonry {
    display: block; /* 關鍵：不能用 grid */
    width: 100%;
    
    /* 設定欄數：預設 5 欄 */
    column-count: 5;
    column-gap: 20px; /* 欄與欄的間距 */
    
    /* 確保內容從左邊開始填入 */
    direction: ltr; 
}
.masonry-item {
    /* 關鍵：防止卡片被切斷到下一欄 */
    break-inside: avoid;
    background: #222;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
    
    /* 這裡使用 margin-bottom 來推開垂直間距 */
    margin-bottom: 20px; 
    
    /* 強制寬度 100% (填滿該欄) */
    width: 100%;
}

.masonry-item:hover {
    transform: translateY(-4px);
    border-color: #444;
}

/* 修正圖片與影片的高度，讓它自動長高 */
.masonry-img-wrapper {
    width: 100%;
    height: auto; /* 關鍵：讓高度自適應 */
    display: block;
    line-height: 0; /* 消除圖片下方的微小縫隙 */
}
.masonry-img-wrapper img,
.masonry-img-wrapper video {
    width: 100%;
    height: auto !important; /* 強制覆寫 inline style 的 height: 100% */
    object-fit: cover;
    display: block;
}

/* --- RWD 響應式欄數調整 --- */
@media (max-width: 1500px) {
    .explore-masonry { column-count: 4; }
}
@media (max-width: 1200px) {
    .explore-masonry { column-count: 3; }
}
@media (max-width: 768px) {
    .explore-masonry { 
        column-count: 2; 
        column-gap: 10px;
    }
    .masonry-item {
        margin-bottom: 10px;
    }
}
.masonry-overlay { position: absolute; bottom: 0; left: 0; width: 100%; padding: 30px 15px 15px 15px; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); opacity: 0; transition: 0.3s; display: flex; align-items: flex-end; }
.masonry-item:hover .masonry-overlay { opacity: 1; }
.overlay-bottom { width: 100%; display: flex; justify-content: flex-end; }
.btn-overlay-like { background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.2); color: white; padding: 6px 12px; border-radius: 20px; display: flex; align-items: center; gap: 6px; cursor: pointer; transition: 0.2s; backdrop-filter: blur(4px); }
.btn-overlay-like:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.4); }
.btn-overlay-like.liked { background: rgba(236, 72, 153, 0.2); border-color: rgba(236, 72, 153, 0.6); }
.like-count { font-size: 0.9rem; font-weight: 500; }
/* @media (max-width: 1600px) { .explore-masonry { column-count: 4; } }
@media (max-width: 1200px) { .explore-masonry { column-count: 3; } }
@media (max-width: 768px) { .explore-masonry { column-count: 2; column-gap: 10px; } .explore-toolbar { flex-direction: column; align-items: stretch; } .filter-btn { justify-content: center; } } */
.search-icon-custom { width: 18px; height: 18px; margin-right: 10px; filter: invert(0.8); opacity: 0.7; }
.explore-toolbar-group { display: flex; flex-direction: column; gap: 15px; margin-bottom: 30px; }
.active-tags-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.active-tag-chip { background: rgba(192, 132, 252, 0.15); border: 1px solid #c084fc; color: #e9d5ff; padding: 6px 14px; border-radius: 20px; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; animation: fadeIn 0.3s; }
.remove-tag { cursor: pointer; font-weight: bold; font-size: 1.1rem; line-height: 1; opacity: 0.7; }
.remove-tag:hover { opacity: 1; color: white; }
.clear-all-btn { background: none; border: none; color: #888; font-size: 0.9rem; cursor: pointer; text-decoration: underline; }
.clear-all-btn:hover { color: #ccc; }
.filter-badge { background: #c084fc; color: white; font-size: 0.75rem; padding: 2px 6px; border-radius: 10px; margin-left: 4px; }
.overlay-top { position: absolute; top: 15px; left: 15px; z-index: 2; }
.author-badge { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); padding: 4px 10px 4px 4px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); }
.author-avatar-small { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.author-avatar-placeholder { width: 24px; height: 24px; border-radius: 50%; background: #a855f7; color: white; font-size: 0.8rem; display: flex; justify-content: center; align-items: center; font-weight: bold; }
.author-name { font-size: 0.85rem; color: white; font-weight: 500; }

/* 篩選 Modal 專用樣式 */
.filter-modal-card { width: 600px; max-width: 95%; display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; background: #0a0a0a; border: 1px solid #222; }
.filter-header { padding: 20px 30px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center; }
.filter-header h3 { margin: 0; color: white; font-size: 1.2rem; }
.modal-close-simple { background: none; border: none; color: #888; font-size: 1.5rem; cursor: pointer; }
.modal-close-simple:hover { color: white; }
.filter-body { padding: 20px 30px; overflow-y: auto; max-height: 60vh; }
.filter-category-title { font-size: 1rem; color: #ffffff; margin-bottom: 12px; margin-top: 10px; font-weight: bold; display: flex; align-items: center; justify-content: flex-start; }
.category-dot { width: 6px; height: 6px; background-color: #ec4899; border-radius: 50%; margin-right: 12px; box-shadow: 0 0 8px rgba(236, 72, 153, 0.8); }
.filter-footer { padding: 25px 30px; border-top: 1px solid #222; display: flex; justify-content: flex-end; gap: 15px; background: #111; }
.tag-btn { border-radius: 8px; font-size: 0.85rem; }
.tag-btn.active { background: linear-gradient(90deg, #a855f7, #ec4899); color: white; border-color: transparent; }
.tags-wrapper { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; padding-left: 20px; margin-bottom: 25px; }
.btn-apply-large { flex: 3; height: 50px; border-radius: 25px; background: linear-gradient(90deg, #a855f7, #ec4899); color: white; font-weight: bold; font-size: 1rem; border: none; cursor: pointer; transition: opacity 0.2s; }
.btn-apply-large:hover { opacity: 0.9; }
.btn-reset-small { flex: 1; height: 50px; border-radius: 25px; background: #1a1a1a; border: 1px solid #333; color: #888; font-weight: 500; font-size: 0.95rem; cursor: pointer; transition: 0.2s; }
.btn-reset-small:hover { border-color: #555; color: white; }
.scrollable::-webkit-scrollbar { width: 6px; }
.scrollable::-webkit-scrollbar-track { background: transparent; }
.scrollable::-webkit-scrollbar-thumb { background-color: #333; border-radius: 3px; }
.scrollable::-webkit-scrollbar-thumb:hover { background-color: #555; }

.dm-content-area { background: #1a1a1a; border-radius: 12px; padding: 20px; margin-bottom: 20px; border: 1px solid #333; }
.dm-section-label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: #888; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; }
.dm-tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.dm-tag-chip { background: rgba(255, 255, 255, 0.1); color: #e0e0e0; padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; border: 1px solid rgba(255, 255, 255, 0.1); }
.dm-author-box { display: flex; align-items: center; gap: 15px; }
.author-avatar-large { width: 48px; height: 48px; border-radius: 50%; background: #444; color: white; font-size: 1.2rem; font-weight: bold; display: flex; justify-content: center; align-items: center; border: 2px solid #333; }
.author-details { display: flex; flex-direction: column; }
.author-name-large { font-size: 1.1rem; font-weight: bold; color: white; }
.author-prompt-hint { font-size: 0.85rem; color: #666; }

/* =========================================
   14. History Page (消費歷史) - 寬版修正
   ========================================= */
.history-container { max-width: 800px; width: 100%; margin: 0 auto; padding: 60px 40px 120px 40px; color: white; min-height: 80vh; box-sizing: border-box; }
.history-header { text-align: center; margin-bottom: 60px; }
.history-header h1 { font-size: 2.5rem; font-weight: 500; color: #ffffff; letter-spacing: 2px; }
.history-list { display: flex; flex-direction: column; gap: 20px; }
.history-card { background-color: #0f0f0f; border: 1px solid #333; border-radius: 24px; padding: 40px 50px; display: flex; justify-content: space-between; align-items: center; transition: transform 0.2s, border-color 0.2s; }
.history-card:hover { border-color: #555; transform: translateY(-2px); }
.h-card-left { display: flex; flex-direction: column; align-items: flex-start; gap: 15px; }
.h-date { color: #888; font-size: 0.95rem; font-family: 'Inter', sans-serif; letter-spacing: 0.5px; }
.h-title { color: white; font-size: 1.6rem; font-weight: 500; margin-bottom: 5px; }
.h-badge { display: inline-block; border: 1px solid #ff66c4; color: #ff66c4; font-size: 0.8rem; padding: 4px 14px; border-radius: 20px; font-weight: bold; background-color: rgba(255, 102, 196, 0.05); }
.h-card-right { display: flex; align-items: center; }
.h-amount { font-size: 1.8rem; font-weight: 500; color: #ffffff; letter-spacing: 1px; }
.h-amount.positive { color: #ff66c4; text-shadow: 0 0 15px rgba(255, 102, 196, 0.3); }
.empty-history { text-align: center; padding: 60px; color: #666; font-size: 1.1rem; border: 1px dashed #333; border-radius: 24px; }
@media (max-width: 768px) { .history-container { padding: 40px 20px; } .history-card { padding: 25px; flex-direction: column; align-items: flex-start; gap: 20px; } .h-card-right { width: 100%; justify-content: flex-end; } .h-title { font-size: 1.3rem; } .h-amount { font-size: 1.5rem; } }

.source-card {
    aspect-ratio: 1/1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: 0.2s;
}
.source-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.source-card:hover {
    filter: brightness(1.1);
}
.source-card.active {
    border-color: #ff66c4;
    box-shadow: 0 0 15px rgba(255, 102, 196, 0.4);
}
.selected-overlay {
    display: none !important; /* 強制不顯示 */
}

.check-icon {
    display: none !important; /* 強制不顯示 */
}

/* 確保 active 狀態只有邊框與陰影 */
.source-card.active {
    border-color: #ff66c4;
    box-shadow: 0 0 15px rgba(255, 102, 196, 0.6); /*稍微增強陰影讓選取更明顯*/
    transform: scale(0.95); /* 選用：稍微縮小一點點，增加按壓感 */
}
/* RWD */
@media (max-width: 900px) {
    .video-gen-layout { grid-template-columns: 1fr; }
    .source-grid { grid-template-columns: repeat(4, 1fr) !important; }
}

.modal-close {
    position: absolute; /* 關鍵：絕對定位 */
    top: 15px;          /* 距離頂部 15px */
    right: 20px;        /* 距離右側 20px */
    background: transparent; /* 去除背景 */
    border: none;       /* 去除邊框 */
    color: #888;        /* 預設灰色 */
    font-size: 2rem;    /* 字體加大 */
    line-height: 1;     /* 行高設為 1，避免被拉長 */
    cursor: pointer;
    z-index: 100;       /* 確保浮在最上層 */
    padding: 0;         /* 移除內距 */
    width: auto;        /* 避免變成橫條 */
    height: auto;
    transition: 0.3s;
}

.modal-close:hover {
    color: white;
    transform: scale(1.1); /* 滑鼠移過去稍微放大 */
}

/* 手機版微調 (如果覺得太靠邊可以調整這裡) */
@media (max-width: 768px) {
    .modal-close {
        top: 10px;
        right: 15px;
        color: #666; /* 確保在深色背景清楚，或改 #fff */
    }
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 4px 0 15px rgba(0,0,0,0.5);
        
        /* 增加底部留白，避免最後一個選項被手機系統的 Bar 擋住 */
        padding-bottom: 120px !important;
    }
}

/* =========================================
   Global Modal RWD 修復 (支援影片/圖片自適應)
   ========================================= */

/* 1. 卡片本體：限制最大高度，並改為 Flex 垂直排列 */
.modal-card {
    background: #111;
    border: 1px solid #333;
    padding: 20px;       /*稍微縮小內距*/
    border-radius: 20px;
    text-align: center;
    width: 100%;
    max-width: 400px;    /* 電腦版最大寬度 */
    
    /* 關鍵：高度控制 */
    max-height: 90vh;    /* 最大不超過視窗 90% */
    display: flex;       /* 開啟 Flex */
    flex-direction: column; /* 垂直排列 */
    position: relative;
    overflow: hidden;    /* 防止圓角跑版 */
}

/* 2. 媒體區塊 (圖片/影片外框)：自動佔滿剩餘空間 */
.modal-image-wrapper {
    width: 100%;
    /* flex: 1 會讓它自動伸縮填滿中間的空間 */
    flex: 1;             
    min-height: 0;       /* 這是 Flex item 能夠縮小的關鍵 */
    margin-bottom: 15px;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    display: flex;       /* 讓內部的 img/video 置中 */
    align-items: center;
    justify-content: center;
}

/* 3. 媒體本體：限制不超過外框 */
.modal-image-wrapper img, 
.modal-image-wrapper video {
    width: 100%;
    height: 100%;
    max-height: 50vh;    /* 限制媒體最大高度，避免太高 */
    object-fit: contain; /* 保持比例，完整顯示內容 */
    display: block;
}

/* 4. 標題與文字：防止被擠壓 */
.modal-title {
    flex-shrink: 0; /* 禁止被壓縮 */
    margin-top: 10px;
}
.modal-desc {
    flex-shrink: 0; /* 禁止被壓縮 */
    max-height: 60px; /* 如果文字太長，限制高度 */
    overflow-y: auto; /* 文字過多可捲動 */
}
.modal-actions {
    flex-shrink: 0; /* 禁止被壓縮 */
}

/* 手機版微調 */
@media (max-width: 768px) {
    .modal-card {
        width: 90%; /* 手機版寬度 */
        max-height: 85vh; /* 手機版高度限制再嚴格一點 */
    }
}

/* 影片類型標記 (顯示在卡片左上角) */
.type-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    background-color: rgba(0, 0, 0, 0.6); /* 半透明黑底 */
    backdrop-filter: blur(2px);           /* 毛玻璃效果 */
    border-radius: 50%;                   /* 圓形 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;                           /* 確保浮在圖片上層 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;                 /* 讓滑鼠點擊能穿透它 */
}

.type-badge img {
    width: 14px;
    height: 14px;
    filter: invert(1); /* 確保圖示是白色的 */
    object-fit: contain;
    display: block;
}

/* 如果您還是喜歡置中播放按鈕的風格，可以用這個 class */
.center-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255,255,255,0.3);
}

/* =========================================
   13. Explore Page (探索頁面) - 滿版瀑布流修正
   ========================================= */

.explore-header {
    margin-bottom: 30px;
    padding-left: 5px; /* 稍微對齊下方的圖 */
}

/* 瀑布流網格設定 */
.explore-masonry {
    width: 100%;
    display: block; /* 確保它是區塊元素 */
    
    /* 預設欄位設定 (大螢幕) */
    column-count: 5; 
    column-gap: 20px; /* 欄與欄的間距 */
}

/* 卡片設定 */
.masonry-item {
    /* 關鍵：防止內容被切斷到下一欄 */
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    
    /* 關鍵：強制寬度 100% 以填滿該欄位 */
    width: 100%; 
    display: block; /* 保持 inline-block 以正確計算間距 */
    
    background: #222;
    border-radius: 16px;
    margin-bottom: 20px; /* 上下間距 (需與 column-gap 視覺一致) */
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s;
    border: 1px solid transparent;
}

.masonry-item:hover {
    transform: translateY(-4px);
    border-color: #444;
    z-index: 2;
}

/* 確保圖片/影片撐滿卡片且高度自適應 */
.masonry-img-wrapper {
    width: 100%;
    display: block;
    line-height: 0;
}

.masonry-img-wrapper img,
.masonry-img-wrapper video {
    width: 100%;
    height: auto !important; /* 重要：讓高度自動長出來 */
    object-fit: cover;
    display: block;
}

/* =========================================
   RWD 自動調整欄位 (關鍵調整)
   這裡決定了什麼寬度會變成幾欄
   ========================================= */

/* 當螢幕小於 1450px 時，才變成 4 欄 */
@media (max-width: 1450px) {
    .explore-masonry { column-count: 4; }
}

/* 當螢幕小於 1150px 時，變 3 欄 */
@media (max-width: 1150px) {
    .explore-masonry { column-count: 3; }
    .explore-container { padding: 20px 20px; } /* 縮小兩側留白 */
}

/* 當螢幕小於 850px 時，變 2 欄 */
@media (max-width: 850px) {
    .explore-masonry { 
        column-count: 2; 
        column-gap: 10px;
    }
    .masonry-item { margin-bottom: 10px; }
    .explore-container { padding: 20px 10px; }
}

/* 1. 外層容器：改用 Grid 系統 */
.explore-masonry {
    display: grid;
    width: 100%;
    
    /* 關鍵：設定 5 欄，每欄 1fr (均分寬度) */
    grid-template-columns: repeat(5, 1fr);
    
    /* 設定間距 */
    gap: 20px;
    
    /* 移除原本的 column 屬性 */
    column-count: auto;
    column-gap: normal;
}

/* 2. 卡片本體 */
.masonry-item {
    /* 改回預設 block */
    display: block;
    width: 100%;
    
    /* 移除之前的 break-inside 設定，Grid 不需要這個 */
    break-inside: auto;
    margin-bottom: 0; /* Grid 的 gap 已經處理了間距，這裡歸零 */
    
    background: #222;
    border-radius: 16px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s;
    border: 1px solid transparent;
}

/* 3. 圖片/影片容器：確保高度一致或自適應 */
.masonry-img-wrapper {
    width: 100%;
    height: 100%; /* 撐滿卡片 */
    display: block;
}

.masonry-img-wrapper img,
.masonry-img-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 關鍵：這會讓圖片填滿空間，裁切掉多餘部分以保持整齊 */
    display: block;
}

/* =========================================
   RWD 響應式：修改 Grid 的欄位數量
   ========================================= */

/* 1400px 以下變 4 欄 */
@media (max-width: 1400px) {
    .explore-masonry { grid-template-columns: repeat(4, 1fr); }
}

/* 1100px 以下變 3 欄 */
@media (max-width: 1100px) {
    .explore-masonry { grid-template-columns: repeat(3, 1fr); }
}

/* 800px 以下變 2 欄 */
@media (max-width: 800px) {
    .explore-masonry { 
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .explore-container { padding: 20px 10px; }
}
/* =========================================
   13. Explore Page (JS 輔助瀑布流版)
   ========================================= */

.explore-masonry {
    display: grid !important;
    width: 100%;
    
    /* 欄位設定：RWD 交給下面的 Media Query */
    grid-template-columns: repeat(5, 1fr);
    
    /* 關鍵：設定列高為 0 (或極小值)，讓 JS 決定要跨幾列 */
    grid-auto-rows: 10px;
    
    /* 這裡的 gap 只負責水平間距；垂直間距由 JS 計算 */
    column-gap: 20px;
    row-gap: 0; /* 垂直間距設為 0，由 JS 加上 margin */
    
    padding-bottom: 50px; /* 底部留白 */
}

.masonry-item {
    display: block;
    width: 100%;
    
    /* 移除所有高度限制 */
    height: auto !important;
    background: #222;
    border-radius: 16px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border: 1px solid transparent;
    
    /* 關鍵：預設間距 */
    margin-bottom: 20px; 
    
    /* 確保自身內容撐開 */
    align-self: start;
}

.masonry-img-wrapper {
    width: 100%;
    height: auto; /* 讓內容決定高度 */
    display: block;
}

.masonry-img-wrapper img,
.masonry-img-wrapper video {
    width: 100%;
    height: auto !important; /* 確保保持原始比例，不裁切 */
    display: block;
    object-fit: contain; /* 改為 contain 或維持 auto，看你想不想裁切 */
}

/* RWD 保持不變 (欄位數量) */
@media (max-width: 1400px) { .explore-masonry { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1100px) { .explore-masonry { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .explore-masonry { grid-template-columns: repeat(2, 1fr); column-gap: 10px; } }

@media (max-width: 768px) {
    .style-grid {
        /* 改用 Flexbox 以便控制置中 */
        display: flex !important; 
        flex-wrap: wrap;
        justify-content: center; /* 水平置中關鍵 */
        gap: 10px; /* 保持間距 */
    }

    .style-card {
        /* 設定寬度：讓一行顯示 2 個 (扣除間距) */
        /* 這樣 4 個選項就會變成漂亮的 2x2 矩陣 */
        width: calc(50% - 6px) !important; 
        flex: 0 0 auto;
        
        /* 如果您堅持要一行 3 個但置中，請將上面改成：
           width: calc(33.33% - 8px) !important; 
        */
    }
}

/* 1. 設定側邊欄為 Flex 垂直容器，並佔滿視窗高度 */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
    
    /* 使用 dvh (Dynamic Viewport Height) 解決手機網址列遮擋問題 */
    height: 100vh; 
    height: 100dvh; 
    
    /* 確保內容過多時可以捲動，但不影響排版結構 */
    overflow-y: auto;
}

/* 2. 讓導覽選單 (中間層) 自動佔滿剩餘空間 */
.nav-menu {
    flex: 1;  /* 關鍵：這會讓它自動變長，把下面的東西推到底部 */
    display: flex;
    flex-direction: column;
    gap: 10px;
    
    /* 增加一點底部邊距，避免跟錢包太擠 */
    margin-bottom: 20px;
}

/* 3. 確保錢包區塊 (底部層的開始) 被推到底 */
.wallet-card {
    margin-top: auto; /* 雙重保險：強制此元素上方留白最大化 */
    flex-shrink: 0;   /* 防止被擠壓變形 */
}

/* 4. 其他底部元素防止被壓縮 */
.lang-container, 
.user-menu-container {
    flex-shrink: 0;
}

/* 5. 手機版特別優化 */
@media (max-width: 768px) {
    /* 1. 側邊欄容器設定 */
    .sidebar {
        display: flex !important;
        flex-direction: column !important;
        
        /* 使用動態視窗高度 */
        height: 100dvh !important; 
        
        /* [關鍵修改] 底部留白調整 
           使用 safe-area-inset-bottom (iPhone 底部橫條高度) + 20px 緩衝
           如果沒有橫條的手機，這會大約是 20px，不會像之前 100px 那麼高
        */
        padding-bottom: calc(env(safe-area-inset-bottom) + 20px) !important;
        
        /* 確保可以捲動 */
        overflow-y: auto;
    }

    /* 2. 導覽選單 (中間層) - 擔任彈簧的角色 */
    .nav-menu {
        /* 這會佔據所有可用空間，把下方的錢包和個人檔案推到最底 */
        flex-grow: 1 !important; 
        
        /* 防止選單內容太少時高度塌陷 */
        min-height: auto; 
    }

    /* 3. 底部元素群組微調 */
    /* 確保錢包、語言、個人檔案緊密排列在底部 */
    .wallet-card {
        margin-top: auto !important; /* 確保它緊貼著 nav-menu 的邊界往下推 */
        flex-shrink: 0;
        margin-bottom: 15px; /* 錢包與語言選單的間距 */
    }

    .lang-container {
        flex-shrink: 0;
        margin-bottom: 15px; /* 語言選單與個人檔案的間距 */
    }

    .user-menu-container {
        flex-shrink: 0;
        margin-top: 0 !important;
        border-top: 1px solid #333; /* 加條線區隔會更有質感 (選用) */
    }
}

/* --- 整體容器 --- */
  .history-page-wrapper {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  }

  /* --- 標題列 (Header Row) --- */
  .history-header-row {
    display: grid;
    /* 定義四個欄位的寬度比例：左側較寬，中間固定，右側固定 */
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 0 40px;
    margin-bottom: 20px;
    color: #666;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
  }
  .col-amount { text-align: right; }
  .col-id { text-align: center; }

  /* --- 卡片樣式 (Card) --- */
  .history-card {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr; /* 與標題列對齊 */
    align-items: center;
    background-color: #0f0f0f; /* 極深灰背景 */
    border-radius: 36px;       /* 大圓角 */
    padding: 25px 40px;
    margin-bottom: 15px;
    transition: transform 0.2s, background-color 0.2s;
  }

  .history-card:hover {
    background-color: #161616; /* Hover 稍微變亮 */
    transform: translateY(-2px);
  }

  /* 1. 左側區塊：圖示 + 文字 */
  .h-section-main {
    display: flex;
    align-items: center;
    gap: 20px;
  }
  .h-icon-box {
    width: 56px;
    height: 56px;
    background-color: #222; /* 圖示背景色 */
    border-radius: 16px;
    flex-shrink: 0;
  }
  /* 如果是儲值，可以換顏色 */
  .positive .h-icon-box { background-color: #1a1a2e; } 

  .h-info-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .h-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
  }
  .h-desc {
    font-size: 0.85rem;
    color: #666;
  }

  /* 2. 日期區塊 */
  .h-section-date {
    font-size: 1rem;
    color: #888;
    font-weight: 500;
  }

  /* 3. ID 區塊 (膠囊樣式) */
  .h-section-id {
    text-align: center;
  }
  .id-badge {
    display: inline-block;
    padding: 6px 14px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #888;
    letter-spacing: 1px;
    font-family: monospace;
  }

  /* 4. 點數區塊 */
  .h-section-amount {
    text-align: right;
  }
  .amount-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
  }
  .amount-num {
    font-size: 2rem; /* 數字很大 */
    font-weight: 800;
    line-height: 1;
  }
  .amount-label {
    font-size: 0.6rem;
    color: #555;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 4px;
  }

  /* 顏色設定 */
  .amount-num.negative {
    color: #fff; /* 扣點顯示白色 */
  }
  .amount-num.positive {
    color: #6d6aff; /* 儲值顯示亮紫色/藍色 */
    text-shadow: 0 0 20px rgba(109, 106, 255, 0.3); /* 發光效果 */
  }

  /* 空狀態 */
  .empty-history {
    text-align: center;
    padding: 60px;
    color: #555;
  }

  /* RWD 手機版適配 */
  @media (max-width: 768px) {
    .history-header-row { display: none; /* 手機版隱藏標題列 */ }
    
    .history-card {
      grid-template-columns: 1fr auto; /* 改為左右兩欄 */
      grid-template-areas: 
        "main amount"
        "date id";
      gap: 15px;
      padding: 20px;
      border-radius: 24px;
    }

    .h-section-main { grid-area: main; }
    .h-section-amount { grid-area: amount; }
    
    .h-section-date { 
      grid-area: date; 
      font-size: 0.8rem;
    }
    
    .h-section-id { 
      grid-area: id; 
      text-align: right;
    }
    
    .h-icon-box {
      width: 40px;
      height: 40px;
    }
    
    .h-title { font-size: 1rem; }
    .amount-num { font-size: 1.5rem; }
  }
