* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft JhengHei", Arial, sans-serif;
  background: #eef3f8;
  color: #253145;
}

header {
  background: linear-gradient(135deg, #2f3f58, #52657f);
  color: white;
  padding: 20px 24px 34px;
}

header h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

header p {
  margin: 8px 0 0;
  font-size: 22px;
  opacity: 0.9;
}

main {
  width: min(1460px, calc(100% - 48px));
  margin: 28px auto 42px;
}

/* =========================================================
   控制列：固定 controlGrid 容器
   第一列：報告範圍 / 分類 / 排序
   第二列：搜尋框
   ========================================================= */

.control-grid {
  display: grid !important;
  grid-template-columns: 1.45fr 0.85fr 0.75fr;
  grid-template-areas:
    "report category sort"
    "search search search";
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.control-grid #reportSelect {
  grid-area: report;
}

.control-grid #categorySelect {
  grid-area: category;
}

.control-grid #sortSelect {
  grid-area: sort;
}

.control-grid #searchInput {
  grid-area: search;
}

/* 保留相容舊 controls，但不再依賴 :has() */
.controls {
  display: contents;
}

select,
input {
  width: 100%;
  height: 54px;
  border: 1px solid #c9d4e2;
  border-radius: 16px;
  padding: 0 20px;
  background: #ffffff;
  color: #111827;
  font-size: 20px;
  outline: none;
  box-shadow: 0 4px 14px rgba(42, 55, 75, 0.04);
}

select:focus,
input:focus {
  border-color: #7288a7;
  box-shadow: 0 0 0 3px rgba(82, 101, 127, 0.16);
}

#searchInput {
  font-size: 20px;
}

/* =========================================================
   統計列：一行精簡
   ========================================================= */

#summaryPanel {
  margin: 12px 0 18px;
}

.compact-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 20px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(42, 55, 75, 0.08);
  color: #5f6b7b;
  font-size: 16px;
}

.compact-summary strong {
  color: #253145;
  font-size: 17px;
}

.compact-summary span {
  position: relative;
  padding-left: 12px;
}

.compact-summary span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #8b98aa;
  transform: translateY(-50%);
}

/* 舊分類 tabs 隱藏 */
#categoryTabs {
  display: none !important;
}

/* =========================================================
   新聞卡片：縮小高度、保留可讀性
   ========================================================= */

#newsContainer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.news-card {
  background: white;
  border-radius: 20px;
  padding: 22px 26px 20px;
  box-shadow: 0 12px 26px rgba(42, 55, 75, 0.08);
  border-left: 5px solid #40536e;
  min-height: 0;
}

.compact-news-card {
  min-height: 0;
}

.tag-row,
.compact-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.keyword,
.semantic-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 6px 12px;
  background: #edf2f7;
  color: #334760;
  font-size: 15px;
  line-height: 1.2;
}

.semantic-tag {
  background: #dde8f6;
}

.news-card h2 {
  margin: 0 0 8px;
  color: #1f2937;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
}

.meta {
  color: #6b7280;
  font-size: 17px;
  margin-bottom: 6px;
}

.report-line {
  color: #738196;
  font-size: 16px;
  margin-bottom: 12px;
}

.news-card p {
  margin: 0 0 10px;
  color: #374151;
  font-size: 17px;
  line-height: 1.55;
}

.news-card a {
  color: #315c9a;
  font-size: 16px;
  text-decoration: none;
  font-weight: 600;
}

.news-card a:hover {
  text-decoration: underline;
}

.empty {
  grid-column: 1 / -1;
  background: white;
  border-radius: 18px;
  padding: 40px;
  text-align: center;
  color: #6b7280;
  font-size: 20px;
  box-shadow: 0 12px 26px rgba(42, 55, 75, 0.08);
}

/* =========================================================
   中等寬度：兩欄舒適排列
   ========================================================= */

@media (max-width: 1100px) {
  .control-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "report category"
      "sort search";
  }

  #newsContainer {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   手機版：才直排
   ========================================================= */

@media (max-width: 680px) {
  main {
    width: min(100% - 24px, 1460px);
    margin-top: 18px;
  }

  header {
    padding: 16px 16px 26px;
  }

  header h1 {
    font-size: 28px;
  }

  header p {
    font-size: 18px;
  }

  .control-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "report"
      "category"
      "sort"
      "search";
  }

  select,
  input {
    height: 48px;
    font-size: 18px;
  }

  .news-card {
    padding: 20px;
  }

  .news-card h2 {
    font-size: 21px;
  }

  .meta,
  .report-line,
  .news-card p,
  .news-card a {
    font-size: 16px;
  }
}