:root {
  /* Color Palette - Morandi Theme */
  --bg-main: #F0F4F8; /* 極淺藍灰 */
  --bg-white: #ffffff;
  --text-main: #333333;
  --text-muted: #7f8c8d;
  --accent-blue: #3498DB;
  --accent-attention: #E74C3C;
  --border-light: #E8F4F8;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05), 0 1px 3px 1px rgba(0,0,0,.05);
  
  --header-bg: #2C3E50; /* 莫蘭迪深藍 */
  --text-header: #ECF0F1;
  --text-header-hover: #FFFFFF;
  
  /* Layout Constants */
  --header-height: 64px;
  --max-width: 1440px;
  --transition-fast: 0.2s ease;

  /* Typography */
  --font-main: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Plus Jakarta Sans', sans-serif;
}

/* Reading Progress Bar */
#reading-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--accent-blue);
  z-index: 999;
  transition: width 0.1s linear;
  pointer-events: none;
}

body:not([data-page-kind="single"]) #reading-progress {
  display: none;
}


* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Container */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header & Nav */
header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 1000;
}

header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-header);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Desktop Nav */
.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: #BDC3C7;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-header-hover);
}

.nav-links a.active {
  color: var(--text-header-hover);
  background: rgba(255, 255, 255, 0.2);
}

/* Hamburger Menu Icon */
#menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1100;
  order: 3;
  margin-left: auto;
}

#menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-muted);
  margin-bottom: 5px;
  transition: 0.3s;
}

/* Main Content */
main {
  flex: 1;
  padding: 24px 0;
}

main > * {
  /* Ensure children (like .news-grid or article) follow the container rule */
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* News Grid Layout - Advanced */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.hero-card {
  grid-column: 1 / -1; /* Occupies full width */
  display: grid;
  grid-template-columns: 3fr 2fr;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
  transition: box-shadow var(--transition-fast);
}

.hero-card:hover, .news-card:hover {
  box-shadow: var(--shadow-sm);
}

.hero-image {
  height: 380px;
  background-size: cover;
  background-position: center;
}

.hero-content {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  margin: 12px 0;
  font-family: var(--font-heading);
}

.hero-title a {
  text-decoration: none;
  color: var(--text-main);
}

.hero-summary {
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Compact Card for Grid */
.news-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition-fast);
}

.card-image {
  height: 200px;
  background-size: cover;
  background-position: center;
}

.card-body {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  margin: 8px 0;
  font-family: var(--font-heading);
}

.card-title a {
  text-decoration: none;
  color: var(--text-main);
}

@media (max-width: 1024px) {
  .hero-card {
    grid-template-columns: 1fr;
  }
  .hero-image {
    height: 300px;
  }
  .hero-content {
    padding: 32px;
  }
}

@media (max-width: 600px) {
  .news-grid {
    grid-template-columns: 1fr;
  }
  .hero-title {
    font-size: 28px;
  }
}

/* RWD for Header/Nav */
@media (max-width: 768px) {
  #menu-toggle {
    display: block;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    background: var(--header-bg);
    flex-direction: column;
    padding: 80px 24px;
    box-shadow: -4px 0 10px rgba(0,0,0,0.3);
    transition: 0.3s ease;
    align-items: flex-start;
  }

  .nav-links.active {
    right: 0;
  }

  /* Hamburger Animation */
  #menu-toggle.active span:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); }
  #menu-toggle.active span:nth-child(2) { opacity: 0; }
  #menu-toggle.active span:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); }

  article {
    padding: 24px;
  }
}

footer {
  padding: 40px 0;
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

footer .container {
  display: block;
}

/* Typography - Article Content */
article {
  background: var(--bg-white);
  padding: 48px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  max-width: 900px;
  margin: 0 auto;
}

.post-meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 16px;
}

.post-content h2, .post-content h3, .post-content h4 {
  font-family: var(--font-heading);
  color: var(--text-main);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.post-content h2 {
  font-size: 28px;
  border-left: 4px solid var(--accent-blue);
  padding-left: 16px;
}

.post-content h3 { font-size: 22px; }

.post-content p {
  font-size: 18px;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  color: #3c4043;
}

.post-content blockquote {
  margin: 2rem 0;
  padding: 1rem 2rem;
  background: #f1f3f4;
  border-left: 4px solid var(--border-light);
  border-radius: 4px;
  font-style: italic;
  color: var(--text-muted);
}

.post-content blockquote p { margin-bottom: 0; }

.post-content pre {
  background: #202124;
  color: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  margin: 2rem 0;
}

.post-content code {
  background: rgba(0,0,0,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent-attention);
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.post-content ul, .post-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.post-content li { margin-bottom: 0.5rem; font-size: 18px; }

/* Ad Container Styling */
.ad-container {
  margin: 32px 0;
  padding: 16px;
  background: #f8f9fa;
  border: 1px dashed var(--border-light);
  border-radius: 8px;
  text-align: center;
  position: relative;
}

.ad-container::before {
  content: "SPONSORED";
  position: absolute;
  top: -10px;
  left: 16px;
  background: var(--bg-white);
  padding: 0 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Category/Tag Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  background: #e8f0fe;
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 8px;
  text-decoration: none;
}

/* Image Consistency */
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Dashboard Components Styles */
.stat-card {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.progress-bar {
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

.compare-table-wrap td {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 15px;
}

.compare-table-wrap tr:last-child td {
  border-bottom: none;
}

.check-mark { color: #1a73e8; font-weight: bold; }
.cross-mark { color: #d93025; font-weight: bold; }

/* No Image Fallback Styles */
.hero-card.no-image {
  grid-template-columns: 1fr;
  background: linear-gradient(135deg, var(--bg-white) 0%, #f1f3f4 100%);
  border-left: 8px solid var(--accent-blue);
}

.hero-card.no-image .hero-content {
  padding: 64px 48px;
}

.hero-card.no-image .hero-title {
  font-size: 44px;
}

.news-card.no-image {
  background: var(--bg-white);
  min-height: 200px;
}

.news-card.no-image .card-body {
  padding: 32px 24px;
}

.news-card.no-image .card-title {
  font-size: 20px;
}

/* Ad Container — Base display helpers */
.ad-container {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Markdown Table Styles */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.post-content thead tr {
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.post-content th {
  padding: 14px 20px;
  text-align: left;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-content td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  color: #3c4043;
  line-height: 1.6;
}

.post-content tbody tr:last-child td {
  border-bottom: none;
}

.post-content tbody tr:nth-child(even) {
  background: #f8faff;
}

.post-content tbody tr:hover {
  background: #e8f0fe;
  transition: background var(--transition-fast);
}

/* Mega Menu */
.nav-item-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  height: 100%;
  color: #BDC3C7;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.nav-item-dropdown:hover {
  color: var(--text-header-hover);
}

.mega-menu {
  display: none;
  position: absolute;
  top: 40px; 
  right: 0;
  background: var(--bg-white);
  color: var(--text-main);
  padding: 2rem;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  width: 600px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  cursor: default;
}

.nav-item-dropdown:hover .mega-menu {
  display: grid;
}

.mega-menu h4 {
  margin: 0 0 1rem 0;
  color: var(--accent-blue);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
  font-family: var(--font-heading);
  font-size: 1rem;
}

.mega-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mega-menu li {
  margin-bottom: 0.5rem;
}

.mega-menu a {
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0;
  background: transparent;
}

.mega-menu a:hover {
  color: var(--accent-blue);
  background: transparent;
}

@media (max-width: 768px) {
  .nav-item-dropdown {
    display: block;
    width: 100%;
    margin-top: 10px;
    color: var(--text-header);
  }
  .nav-links > a {
    color: var(--text-header);
    width: 100%;
    display: block;
  }
  .nav-item-dropdown .mega-menu {
    position: relative;
    top: 0;
    width: 100%;
    background: transparent;
    box-shadow: none;
    grid-template-columns: 1fr;
    padding: 1rem 0 1rem 1rem;
    display: none;
  }
  .nav-item-dropdown:hover .mega-menu, .nav-item-dropdown:active .mega-menu {
    display: grid;
    gap: 0.8rem;
  }
  /* 在手機版隱藏最新文章與查看全部，只留大分類名稱，避免選單過度冗長 */
  .mega-menu ul, .mega-menu > div > div {
    display: none;
  }
  .mega-menu h4 {
    margin: 0;
    border-bottom: none;
  }
  .mega-menu h4 a {
    color: #BDC3C7 !important;
    font-size: 1.1rem;
  }
}

/* --- Social Share Buttons --- */
.share-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2rem 0;
}

.share-bar-top {
  margin: 1rem 0 2rem 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.share-bar-bottom {
  margin-top: 3rem;
  padding: 1.5rem;
  background: var(--bg-main);
  border-radius: 12px;
  justify-content: space-between;
}

.share-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-heading);
}

.share-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--bg-white);
  color: var(--text-main);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.share-bar-top .share-btn {
  padding: 6px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  justify-content: center;
}

.share-btn svg {
  flex-shrink: 0;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Brand specific colors (Morandi variations) */
.share-btn.fb:hover { color: #3b5998; border-color: #3b5998; }
.share-btn.tw:hover { color: #333333; border-color: #333333; }
.share-btn.line:hover { color: #27ae60; border-color: #27ae60; }
.share-btn.ig:hover { color: #bc1888; border-color: #bc1888; }
.share-btn.copy:hover { color: var(--accent-blue); border-color: var(--accent-blue); }

.share-btn.copied {
  background: var(--accent-blue) !important;
  color: white !important;
  border-color: var(--accent-blue) !important;
}

/* Toast Notification */
.share-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(44, 62, 80, 0.95);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.share-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 600px) {
  .share-bar-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}
