/* --- 修正主題切換鈕過高（覆蓋原本 var(--header-h)）--- */
.navbar .nav-list > li > .nav-icon-btn{
  align-self: center;
}

/* ===================================================================
   Header dropdown / mega — Desktop override (貼緊，去掉空白)
   Moved/centralized here so override file controls final positioning.
   Ensures no vertical gap between trigger and menu, and keeps mobile
   behavior intact (mobile rules exist below).
   =================================================================== */
/* Desktop only: make dropdowns sit flush under the trigger */
@media (min-width: 993px) {
  /* simple, high-specificity selectors to override theme.css earlier rules */
  #navbar .dropdown > .menu,
  .navbar .dropdown > .menu {
    position: absolute;
    top: 100%;        /* removed the +8px gap */
    margin-top: 0;    /* ensure no extra spacing */
    right: 0;
    min-width: 200px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-2);
    display: none;
    z-index: 1250; /* slightly higher to be safe */
  }

  /* ensure hover/focus/open display rules still work and use the same selectors */
  #navbar .dropdown:hover > .menu,
  #navbar .dropdown:focus-within > .menu,
  #navbar .dropdown.open > .menu,
  .navbar .dropdown:hover > .menu,
  .navbar .dropdown:focus-within > .menu,
  .navbar .dropdown.open > .menu {
    display: block;
  }

  /* Mega panel: also sit flush */
  #navbar .dropdown .mega,
  .navbar .dropdown .mega {
    position: absolute;
    top: 100%;
    margin-top: 0;
    right: 0;
    width: min(560px, 92vw);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-2);
    padding: 16px;
    display: none;
    gap: 16px;
    z-index: 1250;
  }

  #navbar .dropdown:hover .mega,
  .navbar .dropdown:hover .mega,
  #navbar .dropdown.open .mega,
  .navbar .dropdown.open .mega {
    display: grid; grid-template-columns: 1fr 1fr;
  }
}

/* 實際尺寸（36x36）與樣式 */
.navbar .right-actions .nav-icon-btn{
  width: 36px !important;
  height: 42px !important;
  line-height: 42px !important;
  border-radius: 30% !important;
  display: grid !important;
  place-items: center !important;
  margin-left: 8px;
  margin-right: 4px;
  padding: 5px 0 !important;
}

/* 圖示大小與置中 */
.navbar .right-actions .nav-icon-btn i{
  font-size: 18px;
  line-height: 1;
}
/* ============================================================
   Custom Override — Gallery RWD & Image Fit Fix
   (for Gallery.jsx cards)
   ============================================================ */
.card > a .blur figure {
  margin: 0;
  position: relative;
  overflow: hidden;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.card > a .blur figure > img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  transition: transform 0.25s ease;
}

.card > a .blur figure > img:hover {
  transform: scale(1.02);
}

/* 防止小螢幕時超出容器 */
@media (max-width: 768px) {
  .card > a .blur figure > img {
    aspect-ratio: 1 / 1;
    height: auto;
  }
}

/* hover 時中間文字仍可顯示在圖片上 */
.card .middle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  transition: opacity 0.25s ease;
}

.card:hover .middle {
  opacity: 1;
}
html[data-theme="dark"] .card .card-text {
  color: #f3f4f6; /* 比原 e5e7eb 再亮一階 */
}

/* 主要容器：套用主題背景與間距 */
.highlight-detail-section {
  padding: 24px;
  color: var(--ink);
}

/* 回上頁連結與瀏覽徽章 */
.highlight-detail-section .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
}
.highlight-detail-section .back-link:hover {
  color: var(--brand-2);
}
.highlight-detail-section .view-badge {
  background: rgba(47,125,246,0.08);
  color: var(--brand-2);
  border: 1px solid rgba(47,125,246,0.18);
  border-radius: 999px;
  font-size: 14px;
  padding: 4px 10px;
}

/* 主標題 */
.highlight-detail-section h1 {
  font-weight: 900;
  margin: 8px 0 4px;
  color: var(--ink);
}

/* 副文字（時間、地點、講者） */
.highlight-detail-section .meta {
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.6;
}

/* 圖片卡片 */
.highlight-detail-section .card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* 圖片輪播控制按鈕 */
.highlight-detail-section .card .btn {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  transition: background .2s, transform .1s;
}
.highlight-detail-section .card .btn:hover {
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
  transform: scale(1.05);
}

/* 縮圖列 */
.highlight-detail-section .thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 12px;
}
.highlight-detail-section .thumbs img {
  width: 120px;
  height: 72px;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color .2s;
}
.highlight-detail-section .thumbs img.active {
  border-color: var(--brand);
}

/* 卡片文字區塊（說明、議程、檔案） */
.highlight-detail-section .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  margin-top: 12px;
  color: var(--ink);
}
.highlight-detail-section .card h4 {
  font-weight: 800;
  color: var(--ink);
}

/* 暗黑模式微調（亮文字） */
html[data-theme="dark"] .highlight-detail-section h1,
html[data-theme="dark"] .highlight-detail-section .card h4 {
  color: #f3f4f6;
}

/* ============================================================
   Dark Mode — Announcement Calendar tone-down
   ============================================================ */
html[data-theme="dark"] .cal.card{
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-1);
}

html[data-theme="dark"] .cal-header .cal-title{
  color: var(--ink);
}
html[data-theme="dark"] .cal-header .btn-ghost{
  background: rgba(47,125,246,0.10);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(47,125,246,0.18);
}
html[data-theme="dark"] .cal-header .btn-ghost:hover{
  background: rgba(47,125,246,0.14);
}

/* 星期列：去掉亮底，改為低對比條 */
html[data-theme="dark"] .cal-weekday{
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* 日期格：改用 surface 系列，降低亮度 */
html[data-theme="dark"] .cal-cell{
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.20);
  color: var(--ink);
}
html[data-theme="dark"] .cal-cell.is-out{
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--muted);
}

/* 今日：改用品牌色內圈，不要純亮邊 */
html[data-theme="dark"] .cal-cell.is-today{
  box-shadow: 0 0 0 2px var(--toggle-ring) inset;
}

/* 日期數字 */
html[data-theme="dark"] .cal-date{
  color: var(--ink);
}

/* 活動膠囊：由亮底改為深色混合 + 品牌邊 */
html[data-theme="dark"] .cal-chip{
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--brand) 14%, var(--surface)),
    color-mix(in srgb, var(--brand-2) 10%, var(--surface))
  );
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
}

/* 更多數量 */
html[data-theme="dark"] .cal-more{
  color: var(--muted);
}

/* 連結狀態 */
html[data-theme="dark"] .cal-link:hover .cal-chip{
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
}
html[data-theme="dark"] .cal-link.disabled .cal-chip{
  opacity: .72;
}

/* ============================================================
   Content Blocks for Embedded HTML (dark-mode friendly)
   作用範圍：.card 內的一般內容、表格、圖片、QA 區塊
   ============================================================ */

/* 統一卡片內距（可移除資料檔的 inline padding） */
.card > .news-body { padding: 14px 16px; }

/* 文字排版：在深淺主題都維持足夠對比 */
.card .news-body h3,
.card .news-body h4 { 
  margin: 6px 0 10px; 
  font-weight: 800; 
  color: var(--ink);
}
.card .news-body p,
.card .news-body li { 
  color: var(--ink); 
}

/* 連結顏色沿用全域（:root 中已定義） */

/* 表格：以主題變數呈現，避免亮底刺眼 */
.card .table { 
  width: 100%; 
  border-collapse: collapse; 
}
.card .table th,
.card .table td { 
  border: 1px solid var(--border); 
  padding: 8px; 
  vertical-align: top; 
  color: var(--ink);
}
.card .table thead th { 
  background: color-mix(in srgb, var(--ink) 6%, var(--surface)); 
  font-weight: 800; 
}

/* 圖片：RWD 與視覺和諧 */
.card .news-body img { 
  max-width: 100%; 
  height: auto; 
  border-radius: 8px; 
  box-shadow: var(--shadow-1); 
}

/* QA 區塊（資料檔已有 .qa-list 類） */
.qa-list { margin: 0; padding: 0; list-style: none; }
.qa-list li { margin-bottom: 1rem; }
.qa-list strong { display: block; color: var(--brand); font-size: 1.05rem; }
.qa-list p { margin: .25rem 0 0; }

/* 手機：略縮行高與間距 */
@media (max-width: 560px){
  .cal-cell{ min-height: 92px; }
}

/* ======= 首頁 Banner 樣式 ======= */
.home-banner {
  padding: 4rem 1.5rem; /* 上下留白 */
  margin-bottom: 24px;  /* 與下方區塊隔開 */
  text-align: center;   /* 內容置中 */

  /* 漸層背景 */
  background: linear-gradient(135deg, var(--brand, #2f7df6), var(--brand-2, #6a5acd));

  border-radius: 0 0 var(--radius, 16px) var(--radius, 16px);
  box-shadow: var(--shadow-2, 0 8px 24px rgba(15,23,42,.10));

  /* --- 以下為圖案所需樣式 --- */
  position: relative; /* 讓偽元素可以定位 */
  overflow: hidden;   /* 確保圖案不會超出邊界 */

  animation: none !important;
  transform: none !important;
}

.home-banner .banner-title {
  color: #fff;
  font-weight: 900;
  font-size: 2.25rem;
  margin: 0 0 0.75rem 0;

  /* 覆蓋 .section-headline h2 的漸層文字效果 */
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: #fff !important;
}

.home-banner .banner-subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.125rem;
  font-weight: 500;
  max-width: 600px;
  text-align: center;
  margin: 0 auto 1.5rem auto;
}

.home-banner .btn-primary {
  background: #fff;
  color: var(--brand, #2f7df6);
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.home-banner .btn-primary:hover {
  background: #fff;
  filter: brightness(0.98);
  transform: translateY(-2px);
  color: var(--brand, #2f7df6);
}

/* --- 以下為圖案本身 --- */

/* 醫護圖案 (左下角) */
.home-banner::before {
  content: '\F53B'; /* bi-heart-pulse (心跳) */
  font-family: "bootstrap-icons" !important;
  position: absolute;
  bottom: -10px; /* 稍微往下移 */
  left: 5%;
  font-size: 10rem;
  color: rgba(255, 255, 255, 0.1);
  transform: rotate(-15deg);
  pointer-events: none;
  z-index: 0;
}

/* AI 圖案 (右上角) */
.home-banner::after {
  content: '\F639'; /* bi-robot (機器人) */
  font-family: "bootstrap-icons" !important;
  position: absolute;
  top: -10px; /* 稍微往上移 */
  right: 5%;
  font-size: 12rem;
  color: rgba(255, 255, 255, 0.1);
  transform: rotate(10deg);
  pointer-events: none;
  z-index: 0;
}

/* 確保 Banner 內的文字內容在圖案上方 */
.home-banner .container {
  position: relative;
  z-index: 1; /* 讓內容顯示在偽元素圖案上方 */
}

.home-banner .container {
  .card > .news-body { padding: 12px; }
  .qa-list li { margin-bottom: .75rem; }
}

/* ============================================================
   Dark Mode — Global Readability Fixes (minimal, safe)
   ============================================================ */

/* 1) 一般文字：強制用 var(--ink)；避免被舊樣式蓋掉 */
html[data-theme="dark"] body,
html[data-theme="dark"] main,
html[data-theme="dark"] section,
html[data-theme="dark"] .container,
html[data-theme="dark"] .card {
  color: var(--ink);
}

/* 2) 卡片內容內文與小字（避免過淡） */
html[data-theme="dark"] .card p,
html[data-theme="dark"] .card li,
html[data-theme="dark"] .card small,
html[data-theme="dark"] .card .news-meta {
  color: var(--ink);
}

/* 3) 連結顏色：在暗色底上拉高對比；hover 再亮一點 */
html[data-theme="dark"] a {
  color: var(--brand);
  text-decoration: none;
}
html[data-theme="dark"] a:hover {
  color: var(--brand-2);
}

/* 4) tables（像 about 的 member-table）：邊框與表頭底色變暗、字變亮 */
html[data-theme="dark"] table,
html[data-theme="dark"] .member-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
}
html[data-theme="dark"] .member-table th,
html[data-theme="dark"] .member-table td {
  border: 1px solid var(--border);
  padding: 8px;
  vertical-align: top;
}
html[data-theme="dark"] .member-table th {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--ink);
}

/* 5) 標題在暗色下再亮一階（避免偏灰） */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4 {
  color: #f3f4f6;
}

/* ============================================================
   Dark Mode — 活動議程 / 表格卡片修正
   ============================================================ */

/* 活動議程、檔案下載等 .card 統一使用深色底 */
html[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-1);
}

/* 表格內部邊框與底色修正 */
html[data-theme="dark"] table,
html[data-theme="dark"] .table {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

/* 表頭稍微有層次（低亮度分隔） */
html[data-theme="dark"] thead th {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--ink);
}

/* 滑過列時加一點對比陰影 */
html[data-theme="dark"] tbody tr:hover td {
  background: color-mix(in srgb, var(--brand) 5%, transparent);
}

/* ============================================================
   Home / News list tweaks（dark-friendly）
   ============================================================ */

/* 調整 #news 一致間距（你的全域 section 已有 padding，這裡只做微調） */
#news .container { padding-top: 8px; padding-bottom: 16px; }

/* 右側動作列統一樣式：靠右、對齊、留間距 */
.news-actions{
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

/* 瀏覽數徽章（明暗模式皆清楚） */
.view-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 28px;
  padding: 0 10px;
  border-radius: 10px;
  font-weight: 800;
  line-height: 1;
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  color: color-mix(in srgb, var(--brand-2) 60%, var(--ink));
}

/* 夜間模式再提升對比一點點 */
html[data-theme="dark"] .view-badge{
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  color: #e8edff;
}

/* 小螢幕時，news-card 的內距與排版更貼合 */
@media (max-width: 560px){
  .news-card{ padding: 14px 14px; }
  .news-actions .button{ min-width: auto; padding: 0 12px; }
}

/* ============================================================
   Fine-tune: Home 最新消息 (dark mode polish)
   ============================================================ */

/* 1️⃣ 卡片背景顏色層次：與主背景分開一點，陰影柔和 */
html[data-theme="dark"] .news-card {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border-color: color-mix(in srgb, var(--ink) 18%, transparent);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* 2️⃣ 日期區塊：背景調亮一點、字更清楚 */
html[data-theme="dark"] .news-date {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--brand) 16%, var(--surface)),
    color-mix(in srgb, var(--brand-2) 18%, var(--surface))
  );
  border-color: color-mix(in srgb, var(--brand) 25%, transparent);
}
html[data-theme="dark"] .news-date .day {
  color: #ffffff;
}
html[data-theme="dark"] .news-date .ym {
  color: #d1d5db;
}

/* 3️⃣ 按鈕色階微調：保持主題一致、提升對比 */
html[data-theme="dark"] .button,
html[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}
html[data-theme="dark"] .button:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* 4️⃣ 瀏覽數徽章調亮一些 (配合按鈕一致風格) */
html[data-theme="dark"] .view-badge {
  background: color-mix(in srgb, var(--brand) 20%, transparent);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  color: #fff;
}

/* 5️⃣ 標題強調 (h3.news-title) 保持亮度與行距 */
html[data-theme="dark"] .news-title {
  color: var(--ink);
  line-height: 1.3;
  font-weight: 900;
}

/* ============================================================
   Home / 最新消息 — 對齊重構（Grid 兩欄 + 對齊基準）
   ============================================================ */

/* 讓每張卡片固定為「日期欄  +  內容欄」的 2 欄版型 */
.news-card{
  display: grid;
  grid-template-columns: 92px 1fr; /* 左：日期固定寬；右：內容自適應 */
  gap: 16px;
  align-items: center;             /* 中線對齊；若要頂端改成 start */
}

/* 日期欄：置中排版、固定寬度，避免被壓縮 */
.news-date{
  justify-self: center;
  align-self: center;
  width: 92px;
}

/* 內容欄：垂直節奏固定 */
.news-body{
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0; /* 讓長標題也不把格子撐爆 */
}
.news-title{
  margin: 2px 0 4px;
  line-height: 1.3;
  word-break: break-word;
}

/* 下行：主辦方在左、動作在右，必要時自動換行但保持右側靠齊 */
.news-meta{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.news-actions{
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;   /* 靠右 */
}

/* 徽章與按鈕高度統一，視覺更整齊 */
.view-badge{ height: 28px; line-height: 28px; padding: 0 10px; }
.button, .btn{ height: 36px; }

/* 小螢幕斷點：把日期欄略縮、整體更緊湊 */
@media (max-width: 768px){
  .news-card{
    grid-template-columns: 80px 1fr;
    gap: 12px;
  }
  .news-date{ width: 80px; }
}

/* 超小螢幕：改為直排，仍維持整齊的節奏與靠右動作 */
@media (max-width: 480px){
  .news-card{
    grid-template-columns: 1fr; /* 直排 */
    align-items: start;
  }
  .news-date{
    justify-self: start;
    width: auto;
  }
  .news-actions .button{ min-width: auto; padding: 0 12px; }
}

/* ============================================================
   Fix: Procedure 段落裝飾條過高 & 對齊
   ============================================================ */

/* 2) 調整裝飾條尺寸改用 em，跟隨文字行高；並置中對齊 */
.procedure .row > p:first-of-type::after, .procedure .row > div > p:first-of-type::after{
  width: 10px;                 /* 條的寬度 */
  height: 1.5em;                /* 跟著文字行高走，不會過高 */
  margin: 0 10px;             /* 與文字間距 */
  display: inline-block;      /* 讓 vertical-align 生效 */
  vertical-align: middle;     /* 與文字中線對齊 */
  position: static;           /* 移除原本 relative 導致的位移感 */
  background: #b5970f;        /* 維持你原本的色系 */
}


/* 3) 手機再微縮，避免擠版 */
@media (max-width: 560px){
  .procedure .row > p:first-of-type::after, .procedure .row > div > p:first-of-type::after{
    height: 0.8em;
    margin: 0 8px;
  }
}

/* --- Search 建議/結果面板 --- */
.search-suggest{ width:100%; display:grid; gap:16px; }
.search-suggest .sg-group{ background: var(--surface); border:1px solid var(--border); border-radius:14px; padding:12px; }
.search-suggest .sg-title{ font-weight:800; color:var(--muted); margin-bottom:8px; }
.search-suggest .sg-list{ display:grid; gap:8px; }
.search-suggest .sg-item{ display:block; padding:8px 10px; border-radius:10px; text-decoration:none; color:var(--ink); border:1px solid transparent; }
.search-suggest .sg-item:hover{ background: color-mix(in srgb, var(--brand) 10%, transparent); border-color: color-mix(in srgb, var(--brand) 20%, transparent); }
.sg-item-title{ font-weight:800; }
.sg-item-sub{ font-size:12px; color:var(--muted); margin-top:2px; }
.sg-chips{ display:flex; flex-wrap:wrap; gap:8px; }
/* 全域 chip 樣式（可被更具體的 .sg-chips .chip 覆蓋） */
.chip{
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  transition: background .12s ease, color .12s ease, transform .06s ease, box-shadow .12s ease;
  box-shadow: none;
}
.chip:hover{
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  transform: translateY(-1px);
}
.chip:active{ transform: translateY(0); }
.chip:focus-visible{
  outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent);
  outline-offset: 2px;
}

/* active 狀態（選擇中） */
.chip.active{
  background: var(--brand);
  color: var(--surface);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* 保留 search panel 的 .sg-chips .chip 精細設定（覆蓋全域） */
.sg-chips .chip{ border:0; padding:6px 10px; border-radius:999px; background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); cursor:pointer; }

.search-results{ width:100%; }
.sr-head{ font-weight:800; color:var(--muted); margin:6px 2px 8px; }
.sr-list{ list-style:none; margin:0; padding:0; display:grid; gap:6px; }
.sr-item{ display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:12px; text-decoration:none; color:var(--ink); border:1px solid transparent; }
.sr-item:hover{ background: color-mix(in srgb, var(--brand) 10%, transparent); border-color: color-mix(in srgb, var(--brand) 22%, transparent); }
.sr-item.active{ outline:2px solid color-mix(in srgb, var(--brand) 40%, transparent); }
.sr-cat{ font-size:12px; font-weight:800; color:var(--muted); min-width:72px; }
.sr-title{ font-weight:900; }
.search-results mark{ background: color-mix(in srgb, var(--brand) 35%, #fff); color:inherit; padding:0 2px; border-radius:3px; }
.empty{ color:var(--muted); }

html[data-theme="dark"] .icon-btn {
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
  color: var(--ink); /* 使用主文字色，確保可見 */
  transition: all 0.2s ease;
}
html[data-theme="dark"] .icon-btn:hover {
  background: color-mix(in srgb, var(--brand) 25%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  color: #fff;
}

/* 確保 icon 本身 (bootstrap icon) 也能跟主題切換 */
html[data-theme="dark"] .icon-btn i,
html[data-theme="dark"] .nav-icon-btn i {
  color: var(--ink);
}

/* 若按鈕有透明樣式時，強制給一點陰影邊界避免消失 */
html[data-theme="dark"] .icon-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============================================================
   Fix: Utility Bar 搜尋按鈕（亮/暗色皆清楚、尺寸一致）
   ============================================================ */
.utility-bar .icon-btn{
  /* 覆蓋原本 all:unset 之後的缺省狀態，還原可點/可視樣式 */
  display: grid;
  place-items: center;
  width: 36px;               /* 與導覽 icon 鈕一致 */
  height: 20px;
  padding: 0;
  margin-left: 8px;
  border-radius: 10px;
  line-height: 1;
  cursor: pointer;

  /* 使用主題變數（在 dark 會自動變化） */
  background: var(--toggle-bg-hover);
  border: 1px solid var(--toggle-border);
  color: var(--surface);

  transition: background .18s ease, box-shadow .18s ease, transform .08s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.utility-bar .icon-btn:hover{
  background: var(--toggle-bg-hover);
}
.utility-bar .icon-btn:active{
  transform: translateY(.5px);
}
/* 聚焦可見（鍵盤操作也清楚） */
.utility-bar .icon-btn:focus{ outline: none; }
.utility-bar .icon-btn:focus-visible{
  box-shadow: 0 0 0 2px var(--toggle-ring);
}

/* 放大放大鏡圖示，確保對比 */
.utility-bar .icon-btn i{
  font-size: 16px;   /* 需要更大可改 18px */
  color: currentColor;
}

/* 亮/暗色細節微調（暗色加一點層次） */
html[data-theme="dark"] .utility-bar .icon-btn{
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--ink) 25%, transparent);
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
html[data-theme="dark"] .utility-bar .icon-btn:hover{
  background: color-mix(in srgb, var(--brand) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 38%, transparent);
}

.u-right {
    display: flex;
    align-items: center;
}

#about > .row {
  justify-content: center;
}

/* ============================================================
   Program / 文件下載區樣式（亮暗主題相容）
   ============================================================ */

/* 外層間距與置中對齊 */
#container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  justify-items: start;
  padding: 2rem 1rem !important;
}

/* 中螢幕以上改為 2 欄、桌機以上 3 欄 */
@media (min-width: 768px) {
  #container { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1200px) {
  #container { grid-template-columns: repeat(3, 1fr); }
}

/* 下載連結卡片外觀 */
#container p {
  margin: 0;
}
#container a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.3;
  box-sizing: border-box;
  background: rgba(47, 125, 246, 0.10);
  border: 1px solid rgba(47, 125, 246, 0.25);
  color: var(--brand);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

/* hover 狀態：亮色主題 */
#container a:hover {
  background: rgba(47, 125, 246, 0.16);
  box-shadow: 0 2px 6px rgba(47, 125, 246, 0.25);
}

/* icon 調整 */
#container a i {
  font-size: 18px;
  flex-shrink: 0;
}

/* 暗色模式調整：更亮的字、柔和底色 */
html[data-theme="dark"] #container a {
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 35%, transparent);
  color: #eaf0ff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] #container a:hover {
  background: color-mix(in srgb, var(--brand) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
}

.menu-toggle {
  display: none;
}

/* ============================================================
   Mobile fixes: no horizontal scroll / hard scroll-lock /
   stacked level-1 / text-only level-2 / no over-width
   ============================================================ */

/* A) 全站：禁止水平捲動（杜絕右滑露出面板） */
html, body{ max-width:100%; overflow-x:hidden; }

/* B) 手機版：全版面板（覆蓋層）與硬鎖捲動 */
@media (max-width: 992px){
  /* 面板本體：覆蓋整個視窗，但關閉時不可被點到、也不可被「橫滑」看到 */
  .navbar .nav-list{
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: 100vw !important;
    height: 100svh;
    --panel-px: 16px;
    padding: calc(var(--header-h) + var(--util-h, 0px) + 12px) var(--panel-px) 24px;
    background: var(--surface);
    border: 0;
    box-shadow: var(--shadow-2);
    overflow-y: auto;                 /* 只讓面板自己捲 */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    /* 關閉狀態：完全不可互動，也不佔「可滑出」的空間 */
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;

    transition: transform .22s ease-out, visibility 0s linear .22s;
    z-index: 1101;
  }
  .navbar .nav-list.is-open{
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  /* 畫面上方的 X/漢堡：固定在右上、無怪邊框 */
  .menu-toggle{
    position: fixed;
    top: calc(env(safe-area-inset-top) + 8px);
    right: calc(env(safe-area-inset-right) + 12px);
    z-index: 1102;
    display: grid; place-items: center;
    width: 44px; height: 44px;
    border: none; border-radius: 12px;
    background: color-mix(in srgb, var(--ink) 6%, transparent);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
  }

  /* C) 第一層：直向排列的大按鈕 */
  .navbar .nav-list{ display:flex; flex-direction:column; align-items:stretch; gap:8px; }
  .navbar .nav-list > li > a,
  .navbar .nav-list > li > .drop-title,
  .navbar .nav-list > li > .drop-toggle{
    height: 48px; padding: 0 14px; border-radius: 12px;
  }
  .nav-list .nav-sep{ display:none; }

  /* D) 第二層：純文字向下展開（移除卡片感與圖片） */
  /* 取消先前為了「滿版」加的負邊距，避免超出 100vw */
  #navbar .dropdown>.menu,
  .navbar .dropdown>.menu,
  #navbar .dropdown .mega,
  .navbar .dropdown .mega{
    position: static; display: none;
    margin: 6px 0 10px;
    padding: 4px 0;                 /* 文字列表貼齊面板內距 */
    width: 100%;
    border: 0; border-radius: 0; box-shadow: none;
    background: transparent;        /* 純文字列表，不再鋪滿底色 */
  }
  /* 只用 .open 控制展開 */
  #navbar .dropdown.open>.menu,
  .navbar .dropdown.open>.menu{ display:block !important; }
  #navbar .dropdown.open .mega,
  .navbar .dropdown.open .mega{ display:block !important; }

  /* 純文字樣式 */
  .mega-col h6{ margin: 0 0 6px; font-size: 12px; color: var(--muted); }
  .mega-card{ padding: 0; gap: 0; background: transparent; border: 0; }
  .mega-card img{ display: none; }

  .mega-list{ margin: 0; padding: 0; list-style: none; }
  .mega-list li a,
  #navbar .dropdown>.menu>li>a{
    display: block; padding: 10px 12px; border-radius: 8px;
    color: var(--ink); text-decoration: none;
  }
  .mega-list li a:hover,
  #navbar .dropdown>.menu>li>a:hover{
    background: color-mix(in srgb, var(--ink) 6%, transparent);
  }

  /* E) 日/夜模式鈕：右下角懸浮（不佔排版） */
  .navbar .nav-list > li.right-actions{
    position: fixed;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    margin: 0; z-index: 1102;
  }
  .navbar .right-actions .nav-icon-btn{
    width: 52px !important; height: 52px !important; line-height: 52px !important;
    border-radius: 50% !important;
    background: var(--toggle-bg); border: 1px solid var(--toggle-border);
    box-shadow: var(--shadow-2);
  }

  /* F) 停用 hover 開關（手機只用點擊） */
  #navbar .dropdown:hover>.menu,
  #navbar .dropdown:hover .mega,
  .navbar .dropdown:hover>.menu,
  .navbar .dropdown:hover .mega{ display: none !important; }
}

/* G) 當面板開啟時，硬鎖整頁捲動（含 iOS Safari） */
html.mobile-open,
html.mobile-open body{
  height:100%;
  overflow:hidden !important;
}
html.mobile-open #root{ height:100%; overflow:hidden; }

/* 完全禁止水平捲動（防止右滑露出面板） */
html, body{ max-width:100%; overflow-x:hidden; }

/* 面板開啟時：把 html / body / #root 一起鎖住 */
html.mobile-open,
html.mobile-open body,
html.mobile-open #root{
  height:100%;
  overflow:hidden !important;
}

/* 只讓面板自己滾，避免滾到頁面底層 */
@media (max-width: 992px){
  .navbar .nav-list{
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   Mobile: dropdown = flex-wrap；第二層向下展開（純文字、可點）
   ============================================================ */
@media (max-width: 992px){

  /* ⬇ 1) 第一層容器：照你給的寫法，改成可換行的 flex */
  #navbar .dropdown,
  .navbar .dropdown{
    position: relative;
    display: flex;
    align-items: center;
    align-content: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;       /* ★ 重點：允許第二層換到下一行 */
    gap: 8px;
    width: 100%;
  }

  /* 第一層左右分佈：標題吃滿、箭頭在右 */
  #navbar .dropdown > .drop-title,
  .navbar .dropdown > .drop-title{
    order: 0;
    flex: 0 0 auto;
    min-width: 0;
    height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    display: flex; align-items: center;
  }
  #navbar .dropdown > .drop-toggle,
  .navbar .dropdown > .drop-toggle{
    order: 1;
    flex: 1 1 auto;
    height: 48px;
    padding: 0 12px;
    border-radius: 12px;
    display: flex; align-items: center;
    flex-direction: row-reverse;
  }

  /* ⬇ 2) 第二層：改成「向下展開」的區塊（不再右飄） */
  #navbar .dropdown > .menu,
  .navbar .dropdown > .menu,
  #navbar .dropdown > .mega,
  .navbar .dropdown > .mega{
    order: 2;
    flex: 1 0 100%;        /* ★ 佔滿下一整行 */
    width: 100%;
    position: static !important;  /* ★ 取消 absolute/right:0 等右飄 */
    display: none;                /* 預設收合 */
    margin: 6px 0 10px;
    padding: 0;                   /* 純文字列表，內距由項目決定 */
    background: transparent;
    border: 0; border-radius: 0; box-shadow: none;
    pointer-events: auto;         /* 確保可點 */
  }

  /* 用 .open 控制展開（手機停用 hover 開關） */
  #navbar .dropdown.open > .menu,
  .navbar .dropdown.open > .menu,
  #navbar .dropdown.open > .mega,
  .navbar .dropdown.open > .mega{
    display: block !important;    /* ★ 向下展開 */
  }
  #navbar .dropdown:hover > .menu,
  #navbar .dropdown:hover > .mega,
  .navbar .dropdown:hover > .menu,
  .navbar .dropdown:hover > .mega{
    display: none !important;     /* 手機禁用 hover 彈出 */
  }

  /* ⬇ 3) 第二層純文字樣式（移除卡片/圖片） */
  .mega-card{ display: none !important; }   /* 只留文字 */
  .mega-col h6{ margin: 0 0 6px; padding: 0 18px; font-size: 12px; color: var(--muted); }
  .mega-list{ margin: 0; padding: 0; list-style: none; }
  .mega-highlight { display: none !important;}

  .mega-list li a,
  #navbar .dropdown > .menu > li > a{
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    position: relative; z-index: 1;         /* 避免被任何浮層蓋住 */
  }
  .mega-list li a:hover,
  #navbar .dropdown > .menu > li > a:hover{
    background: color-mix(in srgb, var(--ink) 6%, transparent);
  }

  /* ⬇ 4) 點擊一定可用（提高層級、解除遮擋） */
  .navbar .nav-list{ z-index: 2100; }
  #navbar .dropdown, #navbar .dropdown *{ pointer-events: auto !important; }
}

@media (max-width: 992px){
  #navbar .dropdown, .navbar .dropdown{
    display:flex; flex-wrap:wrap; align-items:center; align-content:flex-start; justify-content:space-between;
  }
  #navbar .dropdown > .menu,
  .navbar .dropdown > .menu,
  #navbar .dropdown > .mega,
  .navbar .dropdown > .mega{
    order:2; flex:1 0 100%;
    position:static !important; width:100% !important; display:none; margin:6px 0 10px; padding:0;
    border:0; border-radius:0; box-shadow:none; background:transparent;
    pointer-events:auto; z-index:1;
  }
  #navbar .dropdown.open > .menu,
  .navbar .dropdown.open > .menu,
  #navbar .dropdown.open > .mega,
  .navbar .dropdown.open > .mega{ display:block !important; }

  /* 第二層純文字 */
  .mega-card{ display:none !important; }
  .mega-list{ margin:0; padding:0; list-style:none; padding: 0 8px !important;}
  .mega-list li a, #navbar .dropdown > .menu > li > a{
    display:block; padding:10px 12px; border-radius:8px; color:var(--ink); text-decoration:none;
  }
  .mega-list li a:hover, #navbar .dropdown > .menu > li > a:hover{
    background: color-mix(in srgb, var(--ink) 6%, transparent);
  }
}
