/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0071e3;
  --primary-dark: #0077ed;
  --accent: #ff6b35;
  --bg: #fbfbfd;
  --surface: #ffffff;
  --border: #d2d2d7;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --tag-bg: #f5f5f7;
  --tag-color: #1d1d1f;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --shadow-hover: 0 8px 32px rgba(0,0,0,.12);
}

body {
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
#site-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.site-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -.01em;
}
.site-title:hover { text-decoration: none; opacity: .75; }

.header-search {
  display: flex;
  align-items: center;
  background: #f5f5f7;
  border: none;
  border-radius: 24px;
  padding: 6px 16px;
  gap: 8px;
  flex: 1;
  max-width: 320px;
}
.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
.header-search input::placeholder { color: #86868b; }
.header-search svg { opacity: .5; flex-shrink: 0; stroke: var(--text); }

/* ===== Nav ===== */
#site-nav {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ===== Layout ===== */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
}

@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { order: 1; }
  #main-content { order: 0; }
}

/* ===== Post Cards ===== */
.posts-grid { display: flex; flex-direction: column; gap: 20px; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 24px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}
.post-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.post-card-meta .date { font-weight: 500; }

.post-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 10px;
  letter-spacing: -.015em;
}
.post-card:hover .post-card-title { color: var(--primary); }

.post-card-excerpt {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.tag {
  display: inline-block;
  background: #f5f5f7;
  color: #6e6e73;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 500;
  border: 1px solid #e0e0e5;
}

/* ===== Post Detail ===== */
#post-detail { display: none; }

.post-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 99px;
  background: transparent;
  margin-bottom: 20px;
  border: 1px solid var(--primary);
  font-family: inherit;
  transition: all .15s;
}
.back-btn:hover { background: var(--primary); color: #fff; }

.post-detail-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 12px;
}

.post-detail-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.post-detail-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 44px;
  box-shadow: var(--shadow);
  font-size: 15.5px;
  line-height: 1.85;
  max-width: 800px;
}

.post-detail-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 36px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.post-detail-body h2:first-child { margin-top: 0; }

.post-detail-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 20px 0 8px;
}

.post-detail-body h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

.post-detail-body p { margin-bottom: 14px; }

.post-detail-body ul, .post-detail-body ol {
  padding-left: 24px;
  margin-bottom: 14px;
}
.post-detail-body li { margin-bottom: 6px; }

.post-detail-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.post-detail-body th, .post-detail-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.post-detail-body th {
  background: #f1f5f9;
  font-weight: 600;
}
.post-detail-body tr:nth-child(even) td { background: #f8fafc; }

.post-detail-body .highlight-box {
  background: #fef3c7;
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
  font-weight: 500;
}

.post-detail-body .info-box {
  background: #eff6ff;
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
}

.qa-block {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
}
.qa-block .question {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.qa-block .answer-tag {
  display: inline-block;
  background: #dcfce7;
  color: #16a34a;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-right: 6px;
}
.qa-block .analysis {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* ===== Sidebar ===== */
#sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-search {
  display: flex;
  gap: 8px;
}
.sidebar-search input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--primary); }
.sidebar-search button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

.label-list { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip {
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 99px;
  cursor: pointer;
  border: 1px solid #d2d2d7;
  transition: all .15s;
}
.label-chip:hover { background: #e8e8ed; }
.label-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.archive-list { list-style: none; }
.archive-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}
.archive-list li:last-child { border-bottom: none; }
.archive-list li:hover { color: var(--primary); }
.archive-list .count {
  background: var(--tag-bg);
  color: var(--primary);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
}

.book-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  font-size: 13px;
  background: #f8fafc;
}
.book-card:last-child { margin-bottom: 0; }
.book-card .book-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.book-card a { font-size: 12px; }

.contact-info { font-size: 13px; color: var(--text-muted); }
.contact-info a { color: var(--primary); }

/* ===== Hero ===== */
#hero-section {
  background: #f5f5f7;
  border-radius: 18px;
  padding: 52px 32px 48px;
  margin-bottom: 24px;
  text-align: center;
}
.hero-inner { max-width: 680px; margin: 0 auto; }
.hero-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 12px;
}
.hero-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -.03em;
  margin-bottom: 10px;
}
.hero-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.7;
}
.hero-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 640px) {
  .hero-cards { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 1.5rem; }
  #hero-section { padding: 36px 20px; }
}
.hero-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 22px 14px 18px;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.hero-card:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
}
.hc-icon { display: flex; justify-content: center; align-items: center; margin-bottom: 12px; }
.hc-label { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 5px; letter-spacing: -.01em; }
.hc-desc { font-size: 11px; color: var(--text-muted); line-height: 1.55; }

/* ===== Empty / Loading States ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: .4; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  background: var(--surface);
  color: var(--text-muted);
  transition: all .15s;
}
.page-btn:hover { border-color: #86868b; color: var(--text); }
.page-btn.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ===== Scroll to top ===== */
#scroll-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: rgba(29,29,31,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: all .2s;
}
#scroll-top:hover { background: rgba(29,29,31,0.9); transform: translateY(-2px); }
#scroll-top.visible { display: flex; }

/* ===== Footer ===== */
#site-footer {
  background: #f5f5f7;
  color: #86868b;
  text-align: center;
  padding: 28px 20px;
  font-size: 12px;
  margin-top: 48px;
  border-top: 1px solid #d2d2d7;
}
#site-footer a { color: var(--primary); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  #app { padding: 16px 14px; gap: 16px; }
  .post-detail-body { padding: 24px 18px; font-size: 15px; }
  .post-detail-header { padding: 20px 16px; }
  .post-detail-title { font-size: 1.25rem; }
}
