:root { --primary: #ffcc00; --bg: #121212; --card-bg: #1e1e1e; --text-color: #f4f4f4; --border: #333; --input-bg: #2a2a2a; --accent: #ff4b2b; }
body.light-mode { --bg: #f4f4f9; --card-bg: #ffffff; --text-color: #333333; --border: #ddd; --input-bg: #f0f0f0; }

body { background-color: var(--bg); color: var(--text-color); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; transition: background-color 0.3s, color 0.3s; }
header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background-color: var(--card-bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.theme-toggle-btn, .menu-toggle-btn { background: transparent; border: 1px solid var(--border); color: var(--text-color); padding: 5px 10px; border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: bold; }

.announcement-bar { background: var(--primary); color: #121212; padding: 8px; overflow: hidden; white-space: nowrap; font-weight: bold; font-size: 14px; }
.marquee { display: inline-block; animation: marquee 15s linear infinite; }
@keyframes marquee { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

.tools-bar { padding: 15px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.search-box, .sort-box, .admin-input { width: 100%; max-width: 400px; padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-color); margin-bottom: 10px; font-size: 16px; }
.price-filter-group { display: flex; align-items: center; gap: 5px; justify-content: center; }
.price-input { max-width: 100px; margin-bottom: 0; }

.filter-container { display: flex; gap: 10px; padding: 10px 15px; flex-wrap: wrap; justify-content: center; }
.filter-btn { background-color: var(--input-bg); color: #888; border: 2px solid var(--border); padding: 8px 16px; border-radius: 20px; cursor: pointer; font-weight: bold; font-size: 14px; transition: 0.3s; }
.filter-btn.active { background-color: var(--primary); color: #121212; border-color: var(--primary); }

.container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px; max-width: 1200px; margin: auto; }
@media (min-width: 768px) { .container { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 20px; } }

/* ✨ 加入 Flexbox 魔法，並設定 height: 100% 確保卡片撐滿網格 */
.card { background-color: var(--card-bg); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.2); position: relative; transition: transform 0.3s, box-shadow 0.3s; border: 1px solid var(--border); display: flex; flex-direction: column; height: 100%; }
.fomo-badge { position: absolute; top: 8px; left: 8px; background: linear-gradient(135deg, #ff416c, #ff4b2b); color: white; padding: 3px 8px; border-radius: 20px; font-weight: bold; font-size: 10px; z-index: 10; }

.image-gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.image-gallery::-webkit-scrollbar { display: none; }
.image-gallery img { width: 100%; height: 130px; object-fit: cover; scroll-snap-align: start; flex: 0 0 100%; }
@media (min-width: 768px) { .image-gallery img { height: 200px; } }

/* ✨ 讓內容區域自動往下長 (flex: 1 1 auto) */
.card-content { padding: 12px; text-align: center; display: flex; flex-direction: column; flex: 1 1 auto; justify-content: flex-start; }
.card-tags { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; justify-content: center; }
.tag-badge-inline { background: var(--primary); color: #121212; font-size: 11px; padding: 2px 6px; border-radius: 4px; font-weight: bold; display: inline-block; }

.card-title { font-size: 15px; font-weight: bold; margin-bottom: 6px; line-height: 1.3; }
@media (min-width: 768px) { .card-title { font-size: 18px; } }

.card-details { font-size: 12px; color: #aaa; margin-bottom: 10px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 768px) { .card-details { font-size: 14px; -webkit-line-clamp: 3; margin-bottom: 15px; } }

/* ✨ 底部群組魔法：強制推到最底下 */
.card-bottom { margin-top: auto; width: 100%; display: flex; flex-direction: column; }
.price-section { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; justify-content: center; flex-wrap: wrap;}
.original-price { text-decoration: line-through; color: #888; font-size: 12px; }
.price { color: var(--primary); font-size: 16px; font-weight: 900; }
@media (min-width: 768px) { .price { font-size: 20px; } .original-price { font-size: 14px; } }
.discount-badge { background: #e74c3c; color: white; padding: 2px 4px; border-radius: 4px; font-size: 11px; vertical-align: middle; }

.card-actions { width: 100%; padding-top: 5px; }

.btn, .view-btn { display: block; width: 100%; padding: 10px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; text-align: center; transition: 0.3s; font-size: 14px; color: #ffffff; -webkit-appearance: none; }
@media (min-width: 768px) { .btn, .view-btn { padding: 12px; font-size: 16px; } }

.view-btn { background: linear-gradient(135deg, var(--primary), #e6b800); color: #121212; box-shadow: 0 2px 8px rgba(255,204,0,0.3); }
.view-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(255,204,0,0.5); }
.view-btn:disabled { background: #555; color: #aaa; box-shadow: none; cursor: not-allowed; transform: none;}

.admin-mode .admin-controls { display: flex !important; }
.admin-controls { display: none; flex-wrap: wrap; gap: 5px; margin-top: 10px; justify-content: center; }
.edit-btn, .sold-btn, .delete-btn { padding: 6px; border: none; border-radius: 4px; color: white; font-weight: bold; cursor: pointer; font-size: 11px; flex: 1 1 30%; -webkit-appearance: none; }
.edit-btn { background-color: #3498db; } .sold-btn { background-color: #2ecc71; } .delete-btn { background-color: #e74c3c; }

.fav-icon { position: absolute; top: 10px; right: 10px; font-size: 20px; cursor: pointer; z-index: 10; text-shadow: 0 2px 4px rgba(0,0,0,0.5); filter: grayscale(100%); transition: 0.3s; }
.fav-icon.active { filter: grayscale(0%); transform: scale(1.1); }
@media (min-width: 768px) { .fav-icon { font-size: 24px; } }

.card.is-sold { opacity: 0.7; }
.sold-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 5; display: flex; justify-content: center; align-items: center; pointer-events: none;}
.sold-text { background-color: #e74c3c; color: white; font-size: 16px; font-weight: 900; padding: 6px 16px; border: 3px solid white; border-radius: 12px; transform: rotate(-15deg); }
@media (min-width: 768px) { .sold-text { font-size: 24px; padding: 10px 35px; border-width: 4px; } }

.card.is-reserved { opacity: 0.85; border-color: #f39c12; }
.reserved-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 5; display: flex; justify-content: center; align-items: center; pointer-events: none;}
.reserved-text { background-color: #f39c12; color: #121212; font-size: 16px; font-weight: 900; padding: 6px 16px; border: 3px solid #121212; border-radius: 12px; transform: rotate(-15deg); box-shadow: 0 5px 20px rgba(0,0,0,0.8); }
@media (min-width: 768px) { .reserved-text { font-size: 24px; padding: 10px 35px; border-width: 4px; } }

#admin-panel { display: none; background: var(--card-bg); margin: 20px; padding: 20px; border-radius: 12px; border: 1px solid var(--primary); text-align: center;}
.smart-paste-area { background: rgba(255,204,0,0.1); padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px dashed var(--primary); }
.dropzone { border: 2px dashed #888; padding: 20px; text-align: center; border-radius: 8px; color: #888; cursor: pointer; margin-bottom: 10px; background: var(--input-bg); }
.dropzone.dragover { border-color: var(--primary); color: var(--primary); background: rgba(255, 204, 0, 0.1); }
#imagePreviewContainer { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-bottom: 15px; }
#imagePreviewContainer img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; }
.modal-content { background-color: var(--card-bg); padding: 20px; border-radius: 12px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; position: relative; border: 1px solid var(--border); }
.close-modal { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,0.7); color: white; width: 34px; height: 34px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 22px; font-weight: bold; cursor: pointer; transition: 0.3s; z-index: 9999; box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.close-modal:hover { background: var(--primary); color: #121212; }

#toast { visibility: hidden; min-width: 250px; background-color: #2ecc71; color: #fff; text-align: center; border-radius: 8px; padding: 16px; position: fixed; z-index: 2000; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 16px; font-weight: bold; box-shadow: 0 4px 15px rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.5s, bottom 0.5s; }
#toast.show { visibility: visible; opacity: 1; bottom: 50px; }
#toast.error { background-color: #e74c3c; }
#toast.info { background-color: #3498db; }

#lightbox { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); justify-content: center; align-items: center; flex-direction: column; }
#lightbox img { max-width: 95%; max-height: 85vh; border-radius: 8px; object-fit: contain; }
.close-lightbox { position: absolute; top: 20px; right: 30px; color: white; font-size: 40px; font-weight: bold; cursor: pointer; z-index: 2001; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.2); color: white; border: none; padding: 15px; font-size: 24px; cursor: pointer; border-radius: 50%; z-index: 2001; transition: 0.3s; }
.lightbox-nav:hover { background: rgba(255,255,255,0.5); }
.lightbox-nav.prev { left: 10px; } .lightbox-nav.next { right: 10px; }

.report-table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 14px; text-align: right; }
.report-table th, .report-table td { border-bottom: 1px solid var(--border); padding: 10px 5px; }
.report-table th { color: #888; font-weight: normal; }
.profit-pos { color: #2ecc71; font-weight: bold; }
.profit-neg { color: #e74c3c; font-weight: bold; }

#admin-stats { display: none; justify-content: space-around; background: var(--card-bg); margin: 0 20px 10px 20px; padding: 15px; border-radius: 12px; border: 1px solid var(--border); text-align: center; }
.stat-box { flex: 1; }
.stat-label { font-size: 12px; color: #888; margin-bottom: 5px; font-weight: bold;}
.stat-value { font-size: 20px; font-weight: 900; }

#sidebar { height: 100%; width: 280px; position: fixed; z-index: 1001; top: 0; left: -280px; background-color: var(--card-bg); overflow-x: hidden; transition: left 0.3s ease; display: flex; flex-direction: column; border-right: 1px solid var(--border); box-shadow: 5px 0 15px rgba(0,0,0,0.5); }
#sidebar.open { left: 0; }
.sidebar-header { padding: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-header h3 { margin: 0; color: var(--primary); font-size: 20px;}
.close-sidebar { color: #888; font-size: 28px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.close-sidebar:hover { color: var(--text-color); }
.sidebar-menu { flex-grow: 1; overflow-y: auto; padding: 10px 0; }
.menu-section-title { padding: 10px 20px; font-size: 12px; color: #888; font-weight: bold; letter-spacing: 1px; }
.sidebar-item { padding: 15px 20px; text-decoration: none; font-size: 16px; color: var(--text-color); display: block; transition: 0.2s; cursor: pointer; font-weight: bold; border-left: 4px solid transparent; }
.sidebar-item:hover, .sidebar-item.active { background-color: rgba(255, 204, 0, 0.1); color: var(--primary); border-left-color: var(--primary); }
#sidebarOverlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1000; }

.starter-view-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; min-height: 60vh; }
.starter-title { font-size: 28px; font-weight: 900; color: var(--primary); margin-bottom: 20px; text-align: center; }
.starter-link-btn { background: var(--input-bg); border: 1px solid var(--border); color: var(--text-color); padding: 15px 30px; font-size: 18px; font-weight: bold; border-radius: 12px; text-decoration: none; transition: 0.3s; width: 100%; max-width: 300px; text-align: center; display: block; }
.starter-link-btn:hover { background: var(--primary); color: #121212; transform: translateY(-3px); box-shadow: 0 5px 15px rgba(255,204,0,0.3); }

.login-area { text-align: center; padding: 40px; }
.login-btn { background: transparent; border: 1px solid #555; color: #888; padding: 8px 16px; border-radius: 20px; cursor: pointer; transition: 0.3s; font-weight: bold;}
.login-btn:hover { color: var(--text-color); border-color: var(--text-color); }
.footer-stats { text-align: center; padding: 20px; color: #666; font-size: 12px; }

#backToTop { display: none; position: fixed; bottom: 20px; right: 20px; z-index: 99; font-size: 24px; border: none; outline: none; background-color: var(--primary); color: #121212; cursor: pointer; padding: 15px; border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,0.3); width: 55px; height: 55px; justify-content: center; align-items: center; text-decoration: none; transition: transform 0.3s, background-color 0.3s; }
#backToTop:hover { background-color: #e6b800; transform: translateY(-5px); }

#skeleton-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px; max-width: 1200px; margin: auto; }
@media (min-width: 768px) { #skeleton-container { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 20px; } }
.skeleton-card { background: var(--card-bg); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); display: flex; flex-direction: column; height: 100%;}
.skeleton-img { height: 130px; background: linear-gradient(90deg, var(--input-bg) 25%, #333 50%, var(--input-bg) 75%); background-size: 200% 100%; animation: loading 1.5s infinite; }
@media (min-width: 768px) { .skeleton-img { height: 200px; } }
.skeleton-content { padding: 12px; display: flex; flex-direction: column; align-items: center; flex-grow: 1;}
.skeleton-line { height: 12px; background: var(--input-bg); margin-bottom: 10px; border-radius: 4px; background: linear-gradient(90deg, var(--input-bg) 25%, #333 50%, var(--input-bg) 75%); background-size: 200% 100%; animation: loading 1.5s infinite; width: 100%;}
.skeleton-line.title { height: 16px; width: 80%; margin-bottom: 10px; }
.skeleton-line.price { height: 20px; width: 50%; margin-top: auto; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.load-more-container { text-align: center; padding: 20px; display: none; }
.infinite-loading-text { color: var(--primary); font-weight: bold; font-size: 16px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

.modal-gallery-container { position: relative; width: 100%; margin-bottom: 15px; border-radius: 8px; overflow: hidden; }
.modal-gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.modal-gallery::-webkit-scrollbar { display: none; }
.modal-gallery img { width: 100%; flex: 0 0 100%; scroll-snap-align: start; object-fit: contain; max-height: 350px; background: #000; cursor: zoom-in; }
.gallery-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.5); color: white; border: none; padding: 10px 15px; cursor: pointer; font-size: 18px; border-radius: 5px; transition: 0.3s;}
.gallery-nav:hover { background: rgba(0,0,0,0.8); }
.gallery-nav.prev { left: 5px; } .gallery-nav.next { right: 5px; }
.gallery-dots { display: flex; justify-content: center; gap: 5px; margin-bottom: 15px; }
.dot { width: 8px; height: 8px; background: #555; border-radius: 50%; transition: 0.3s; }
.dot.active { background: var(--primary); width: 20px; border-radius: 4px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }