* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  background: #f5f6f8;
  color: #222;
  line-height: 1.6;
}

/* Header */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 20;
}
.hdr-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
}
.brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111;
  text-decoration: none;
}
.line-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #06c755;
  color: #fff;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.line-btn:hover { background: #05b24c; }
.line-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  font-weight: 900;
  font-size: 0.72rem;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  gap: 12px;
}
@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 160px 1fr 160px;
    padding: 16px;
    gap: 16px;
  }
}

/* Ad slots */
.ad-slot { display: none; }
@media (min-width: 1024px) {
  .ad-slot { display: block; }
}
.ad-placeholder {
  background: #e5e7eb;
  color: #6b7280;
  font-size: 0.8rem;
  text-align: center;
  border-radius: 8px;
  padding: 30px 10px;
  border: 1px dashed #9ca3af;
}
.ad-placeholder.wide { padding: 20px; }
.ad-slot .ad-placeholder {
  min-height: 600px;
  position: sticky;
  top: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 左側合作推薦卡 */
.partner-card {
  display: block;
  position: sticky;
  top: 70px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: #111;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid #e5e7eb;
}
.partner-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  border-color: #c2410c;
}
.partner-label {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 5px 10px;
  text-align: center;
  letter-spacing: 0.05em;
}
.partner-card img {
  width: 100%;
  height: auto;
  display: block;
}
.partner-info {
  padding: 10px 12px 14px;
}
.partner-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e3a8a;
  line-height: 1.3;
  margin-bottom: 4px;
}
.partner-author {
  font-size: 0.72rem;
  color: #6b7280;
  margin-bottom: 8px;
}
.partner-quote {
  font-size: 0.75rem;
  color: #374151;
  line-height: 1.5;
  padding: 8px 10px;
  background: #f9fafb;
  border-left: 2px solid #f59e0b;
  border-radius: 4px;
  margin-bottom: 10px;
}
.partner-cta {
  font-size: 0.78rem;
  color: #c2410c;
  font-weight: 600;
  text-align: right;
}
.ad-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 12px 20px;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #c2410c 0%, #f97316 60%, #fb923c 100%);
  color: #fff;
  border-radius: 14px;
  padding: 36px 22px;
  text-align: center;
  margin-bottom: 20px;
}
.hero h1 {
  margin: 0 0 12px;
  font-size: 1.6rem;
  line-height: 1.3;
}
@media (min-width: 640px) {
  .hero h1 { font-size: 2rem; }
}
.hero .sub {
  margin: 0 0 22px;
  color: #fed7aa;
  font-size: 0.95rem;
}
.cta-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  margin: 0 auto;
}
@media (min-width: 640px) {
  .cta-group { flex-direction: row; max-width: 620px; }
}
.cta {
  flex: 1;
  padding: 14px 24px;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.cta-primary {
  background: #fff;
  color: #c2410c;
}
.cta-primary:hover { background: #fff7ed; }
.cta-secondary {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.5);
}
.cta-secondary:hover { background: rgba(255,255,255,0.25); }
.hero-meta {
  margin: 18px 0 0;
  color: #fed7aa;
  font-size: 0.8rem;
}

/* Analysis section */
.analysis { scroll-margin-top: 70px; }
.analysis.hidden { display: none; }

/* Tabs */
.tabs-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 14px;
}
.tabs {
  position: relative;
  display: inline-flex;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.tab {
  position: relative;
  z-index: 1;
  min-width: 80px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  color: #6b7280;
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.18s ease;
}
.tab.active { color: #111827; font-weight: 600; }
.tab:not(.active):hover { color: #374151; }
.tab-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(33.333% - 3px);
  height: calc(100% - 8px);
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}
.tabs[data-idx="1"] .tab-indicator { transform: translateX(100%); }
.tabs[data-idx="2"] .tab-indicator { transform: translateX(200%); }

/* Cards */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card h2 { margin: 0 0 10px; font-size: 1rem; color: #111; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.filter-bar select {
  padding: 6px 10px;
  font-size: 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}
.meta { color: #6b7280; font-size: 0.85rem; margin-left: auto; }

.chart-wrap { position: relative; width: 100%; height: 260px; }
@media (min-width: 640px) {
  .chart-wrap { height: 320px; }
}

/* Generator */
.generator .hint { margin: 0 0 10px; font-size: 0.85rem; color: #6b7280; }
.primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.primary:active { background: #1d4ed8; }
.primary:disabled { background: #9ca3af; cursor: not-allowed; }
.generator.locked-mode .admin-only { display: none; }
.generator:not(.locked-mode) .user-only { display: none; }
.generator.locked-mode .admin-row { display: none; }
.gen-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  font-size: 0.82rem;
}
.admin-who { color: #059669; font-weight: 600; }
.logout-link {
  color: #6b7280;
  text-decoration: none;
  font-size: 0.8rem;
}
.logout-link:hover { color: #111; text-decoration: underline; }
.line-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: #06c755;
  color: #fff !important;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
}
.line-login-btn:hover { background: #05b24c; }
.ad-gate-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: #f97316;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.ad-gate-btn:hover { background: #ea580c; }

/* Ad Modal */
.ad-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.ad-modal.open { display: flex; }
.ad-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}
.ad-modal-box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 0;
  width: calc(100% - 24px);
  max-width: 360px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.ad-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f3f4f6;
  font-size: 0.8rem;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}
.ad-modal-title { font-weight: 600; }
.ad-countdown { color: #f97316; font-variant-numeric: tabular-nums; }
.ad-content {
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #fafafa;
}
.ad-placeholder-box {
  text-align: center;
  color: #9ca3af;
  font-size: 0.95rem;
  padding: 40px 20px;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
.ad-placeholder-box small { display: block; margin-top: 6px; font-size: 0.75rem; }
.ad-close-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.ad-close-btn:disabled {
  background: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
}
.ad-close-btn:not(:disabled):hover { background: #1d4ed8; }
.gen-result {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gen-mode-label {
  margin: 0 0 2px;
  font-size: 0.8rem;
  color: #059669;
  font-weight: 600;
  background: #ecfdf5;
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 3px solid #10b981;
}
.gen-set {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.gen-set .label { font-size: 0.85rem; color: #6b7280; margin-right: 4px; }
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #2563eb;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.9rem;
}
.ball.special { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.ball.second { background: #ef4444; border-color: #ef4444; color: #fff; }

/* Articles */
.articles { margin: 30px 0 20px; }
.section-title {
  font-size: 1.3rem;
  color: #111;
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid #2563eb;
}
.article-toc {
  background: #fff;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 4px solid #2563eb;
}
.toc-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #111;
}
.toc-list {
  margin: 0;
  padding-left: 20px;
  columns: 1;
  font-size: 0.88rem;
  line-height: 1.8;
}
@media (min-width: 640px) {
  .toc-list { columns: 2; column-gap: 20px; }
}
.toc-list li { break-inside: avoid; }
.toc-list a {
  color: #1e3a8a;
  text-decoration: none;
}
.toc-list a:hover { text-decoration: underline; color: #2563eb; }

.article {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  scroll-margin-top: 70px;
}
.article h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: #1e3a8a;
}
.article p {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #374151;
}
.article p:last-child { margin-bottom: 0; }
.article b { color: #111; }

/* Static pages (privacy/about) */
.page-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.page-title {
  font-size: 1.6rem;
  color: #111;
  margin: 0 0 6px;
  padding-bottom: 10px;
  border-bottom: 2px solid #2563eb;
}
.page-meta {
  color: #6b7280;
  font-size: 0.85rem;
  margin: 0 0 20px;
}
.nav-links a {
  color: #2563eb;
  text-decoration: none;
  margin: 0 4px;
}
.nav-links a:hover { text-decoration: underline; }

/* LINE Modal */
.line-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.line-modal.open { display: flex; }
.line-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
}
.line-modal-box {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 22px 20px 18px;
  width: calc(100% - 32px);
  max-width: 340px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  animation: popIn 0.18s ease-out;
}
@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.line-modal-box h3 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  color: #111;
}
.line-modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.line-modal-close:hover { background: #f3f4f6; color: #111; }
.line-qr {
  width: 220px;
  height: 220px;
  margin: 0 auto 12px;
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.line-qr img { width: 100%; height: 100%; object-fit: contain; }
.qr-placeholder {
  color: #9ca3af;
  font-size: 0.85rem;
  padding: 12px;
  text-align: center;
}
.line-id-row {
  margin: 6px 0 4px;
  font-size: 1rem;
  color: #111;
}
.line-id-row b { color: #06c755; letter-spacing: 0.05em; }
.line-modal-hint {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #6b7280;
}

/* Footer */
footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: #6b7280;
  font-size: 0.85rem;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  margin-top: 30px;
}
footer p { margin: 6px 0; }
.disclaimer {
  max-width: 720px;
  margin: 0 auto 10px !important;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 10px;
  background: #f9fafb;
  border-radius: 6px;
}
.copyright { font-size: 0.75rem; color: #9ca3af; }
