/* 基礎設定 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: system-ui, -apple-system, "Microsoft JhengHei", sans-serif; background: #f4f6f9; color: #333333; line-height: 1.6; }
body.no-scroll { overflow: hidden; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; }
textarea { resize: vertical; min-height: 90px; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.hidden { display: none !important; }
.page-section { padding-top: 2rem; padding-bottom: 3rem; min-height: 80vh;}

/* 頂部導覽列 Navbar */
.navbar { background: #ffffff; position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,0.06); height: 70px; display: flex; align-items: center; transition: 0.3s; }
.navbar-inner { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; }
.logo img { max-height: 40px; width: auto; object-fit: contain; display: block; }

.nav-right { display: flex; align-items: center; gap: 0.8rem; }
.search-bar { padding: 0.55rem 1.2rem; border-radius: 999px; border: 1px solid #ddd; background: #f8f9fa; color: #333; width: 220px; transition: 0.3s; }
.search-bar:focus { outline: none; border-color: #18293A; background: #fff; }

.btn-login, .small-btn, .btn-submit, .claim-btn { padding: 0.55rem 1.2rem; border: none; border-radius: 999px; background: #18293A; color: white; cursor: pointer; font-weight: bold; transition: 0.25s; }
.btn-login:hover, .btn-submit:hover, .small-btn:hover, .claim-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.nav-text-btn { background: none; border: none; color: #18293A; font-weight: bold; cursor: pointer; padding: 0.5rem; font-size: 1rem; }

/* ✨ 手機版選單：改為固定顯示 (拔除 display: none，加上 margin-left 讓它跟左邊保持距離) */
.hamburger { display: flex; background: none; border: none; flex-direction: column; gap: 5px; cursor: pointer; margin-left: 10px; }
.hamburger span { display: block; width: 26px; height: 3px; background: #18293A; border-radius: 2px;}
.mobile-menu { position: fixed; top: 0; right: -100%; width: 280px; height: 100vh; background: #ffffff; z-index: 1100; padding: 1.5rem; transition: right 0.3s ease; overflow-y: auto; box-shadow: -4px 0 15px rgba(0,0,0,0.05); }
.mobile-menu.active { right: 0; }
.mobile-menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.mobile-nav-links a { color: #333; display: block; padding: 0.8rem 0; font-size: 1.1rem; border-bottom: 1px solid #f0f0f0; }
.mobile-nav-links .menu-divider { height: 12px; border: none; background: transparent; }
.close-btn { background: none; border: none; color: #333; font-size: 2.2rem; cursor: pointer; }

/* 彈窗與遮罩 */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); opacity: 0; visibility: hidden; transition: 0.3s; z-index: 900; }
.overlay.active { opacity: 1; visibility: visible; }
.modal { display: none; position: fixed; z-index: 2000; inset: 0; align-items: center; justify-content: center; }
.modal.show { display: flex !important; }
.modal-content { background-color: #fff; border-radius: 16px; padding: 2rem; width: 90%; max-width: 400px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 16px; color: #888; font-size: 1.5rem; cursor: pointer;}
.modal-title { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; color: #18293A; }

/* 登入註冊表單 */
.auth-form { display: none; }
.auth-form.active { display: block; }
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: #444; font-size: 0.95rem;}
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; }
.form-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.3rem; font-size: 0.95rem; }
.switch-link { color: #18293A; font-weight: 600; }
.signup-link { text-align: center; margin-top: 1.2rem; font-size: 0.95rem; color: #666;}

/* 首頁 Banner & 卡片 */
.home-banner { width: 100%; height: 280px; background: linear-gradient(135deg, #e2e8f0, #cbd5e1); border-radius: 16px; margin-bottom: 2.5rem; display: flex; align-items: center; justify-content: center; color: #18293A; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.section-title { font-size: 2rem; margin-bottom: 0.5rem; color: #18293A; }
.result-text { color: #666; margin-bottom: 1.25rem; }
.filter-toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* 首頁作品網格：強制 9:16 直圖 */
.comic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; }
.comic-card { background: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.05); transition: transform 0.3s ease; cursor: pointer; }
.comic-card:hover { transform: translateY(-5px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.cover { width: 100%; aspect-ratio: 9 / 16; background: #f0f0f0; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comic-card h3 { font-size: 1.15rem; color: #18293A; margin: 12px 14px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.comic-card .tag { font-size: 0.85rem; color: #5c7c99; margin: 0 14px 14px; }

/* 詳情頁：雙欄排版，強制 1:1 方圖 */
.chapter-layout-grid { display: grid; grid-template-columns: 280px 1fr; gap: 3rem; align-items: start; }
.detail-left-column { display: flex; flex-direction: column; gap: 1rem; }
.comic-detail-cover { width: 100%; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); object-fit: cover; aspect-ratio: 1 / 1; }
.detail-text-area { background: transparent; }
.comic-detail-title { font-size: 1.8rem; color: #18293A; margin-bottom: 0.5rem; font-weight: 800; }
.comic-detail-desc { color: #444; font-size: 0.95rem; line-height: 1.7; border-top: 1px solid #ddd; padding-top: 1rem; margin-top: 1rem;}
.chapter-list-wrap { background: #fff; padding: 2rem; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.chapter-btn { width: 100%; text-align: left; margin-bottom: 0.8rem; padding: 1rem 1.2rem; border: 1px solid #eee; border-radius: 12px; background: #f8f9fa; color: #333; cursor: pointer; font-size: 1.05rem; font-weight: bold; transition: 0.2s; display: flex; justify-content: space-between; align-items: center;}
.chapter-btn:hover { background: #e2e8f0; border-color: #cbd5e1;}

/* 閱讀頁頂部 & 排版微調 */
.chapter-read-controls { position: fixed; top: 0; left: 0; width: 100%; height: 70px; z-index: 2000; background: white; border-bottom: 1px solid #e2e8f0; box-shadow: 0 2px 10px rgba(0,0,0,0.04); }
.reader-header-inner { display: flex; justify-content: space-between; align-items: center; width: 100%; height: 100%; position: relative; }
.controls-left { display: flex; align-items: center; z-index: 10; gap: 12px;}
.controls-right { display: flex; align-items: center; z-index: 10;}
.reader-top-title { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 700; font-size: 1.15rem; color: #334155; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; text-align: center; letter-spacing: 1px;}
.reader-page-image { width: 100%; max-width: 900px; display: block; margin: 0 auto 1.5rem; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);}

/* 閱讀頁：右側滑出目錄 */
.chapter-drawer { position: fixed; top: 0; right: -320px; width: 320px; height: 100vh; background: #fff; z-index: 2100; box-shadow: -4px 0 15px rgba(0,0,0,0.1); transition: right 0.3s ease; display: flex; flex-direction: column;}
.chapter-drawer.active { right: 0; }
.drawer-header { padding: 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; }
.drawer-list { flex: 1; overflow-y: auto; padding: 10px; }
.drawer-chapter-btn { display: block; width: 100%; text-align: left; padding: 14px 15px; border: none; background: none; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: 0.2s; font-size: 1.05rem; font-weight: 500; color: #444;}
.drawer-chapter-btn:hover { background: #f0f4f8; }
.drawer-chapter-btn.active { background: #e2e8f0; font-weight: bold; color: #18293A; border-left: 5px solid #18293A; }

/* 閱讀頁：底部按鈕列 */
.reader-bottom-actions { max-width: 900px; margin: 2rem auto 4rem; text-align: center; }
.interaction-btns { display: flex; justify-content: center; gap: 1rem; margin-bottom: 2rem; }
.action-btn { padding: 0.8rem 1.5rem; border-radius: 999px; border: 1px solid #ddd; background: white; font-weight: bold; color: #444; cursor: pointer; transition: 0.2s; font-size: 1rem;}
.action-btn:hover { background: #f8f9fa; border-color: #ccc;}
.nav-btns { display: flex; justify-content: space-between; gap: 1rem;}
.nav-btn { flex: 1; padding: 1rem; border-radius: 12px; background: #18293A; color: white; font-weight: bold; cursor: pointer; border: none; transition: 0.2s; font-size: 1.05rem;}
.nav-btn:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(24,41,58,0.2);}
.nav-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; box-shadow: none;}

/* 使用者下拉選單 */
.user-area { position: relative; }
.btn-user { padding: 4px 10px 4px 4px; display: flex; align-items: center; gap: 8px; background: #f0f0f0; color: #18293A; border: none; border-radius: 999px; font-weight: bold; cursor: pointer; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.user-dropdown { position: absolute; top: 100%; right: 0; background: white; border: 1px solid #eee; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); min-width: 150px; margin-top: 10px; padding: 6px 0; z-index: 100; }
.user-dropdown li a { display: block; padding: 10px 16px; color: #333; font-size: 0.95rem;}
.user-dropdown li a:hover { background: #f4f6f9; color: #18293A; font-weight: bold;}

/* 創作者中心 Tabs & 折疊 */
.creator-tabs { display: flex; gap: 20px; border-bottom: 2px solid #e2e8f0; margin-bottom: 24px; }
.tab-btn { background: none; border: none; font-size: 1.1rem; color: #64748b; font-weight: bold; cursor: pointer; padding: 10px 15px; position: relative; transition: 0.3s; }
.tab-btn:hover { color: #18293A; }
.tab-btn.active { color: #18293A; }
.tab-btn.active::after { content: ''; position: absolute; bottom: -2px; left: 0; width: 100%; height: 3px; background: #18293A; border-radius: 3px 3px 0 0; }
.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.card-header-toggle { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding-bottom: 10px; border-bottom: 1px solid #eee; margin-bottom: 15px; }
.card-header-toggle h3 { margin-bottom: 0 !important; color: #18293A; }
.toggle-icon { font-size: 1.2rem; color: #18293A; transition: transform 0.3s ease; }
.toggle-icon.collapsed { transform: rotate(-90deg); color: #94a3b8; }
.hidden-content { display: none !important; }

/* 表格與操作按鈕 */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 10px;}
.data-table th, .data-table td { border-bottom: 1px solid #eee; padding: 12px; text-align: left; font-size: 0.95rem; }
.data-table th { color: #18293A; font-weight: bold; }
.data-table th:last-child, .data-table td:last-child { white-space: nowrap; width: 140px; text-align: center;}
.btn-action { background: #e2e8f0; border: none; padding: 6px 16px; border-radius: 4px; cursor: pointer; color: #334155; font-size: 0.9rem; font-weight: bold; transition: 0.2s; white-space: nowrap;}
.btn-action:hover { opacity: 0.8; background: #cbd5e1;}

/* 寬版編輯彈窗 */
.edit-modal-container { background: white; width: 95%; max-width: 850px; border-radius: 16px; padding: 2.5rem; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.edit-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; border-bottom: 2px solid #f1f5f9; padding-bottom: 1rem; }
.edit-form-wide .edit-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.edit-form-actions { display: flex; justify-content: flex-end; margin-top: 1.5rem; }

/* 任務卡片 */
.task-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.task-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: #18293A; }
.task-desc { color: #666; font-size: 0.92rem; margin-bottom: 0.7rem; }
.task-meta { font-size: 0.9rem; color: #18293A; font-weight: bold; margin-bottom: 0.8rem; }
.task-progress { margin-bottom: 0.8rem; color: #888; font-size: 0.92rem; }
.claim-btn { width: 100%; }
.claim-btn.disabled { background: #e0e0e0; color: #999; cursor: not-allowed; }
.no-result { display: none; text-align: center; margin-top: 2rem; color: #666; font-size: 1.05rem; }
.show-no-result { display: block !important; }

/* RWD */
@media (max-width: 992px) {
  .search-bar, .btn-login, .user-area { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .comic-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 768px) {
  .chapter-layout-grid { grid-template-columns: 1fr; }
  .edit-form-wide .edit-form-grid { grid-template-columns: 1fr; }
  .mobile-hide { display: none !important; }
  .reader-top-title { font-size: 1.1rem; max-width: 50%; }
}

/* 頁尾 Footer */
.site-footer {
  width: 100%;
  background: #e5e5e5;
  text-align: center;
  padding: 18px 0;
  margin-top: 50px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #666;
}

.footer-links a {
  color: #666;
  transition: 0.2s;
}

.footer-links a:hover {
  color: #18293A;
}

.footer-copy {
  font-size: 0.85rem;
  color: #777;
  text-align: center;
  width: 100%;
}