body.dictionary-page {
  display: block;
  align-items: unset;
  justify-content: unset;
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(147, 197, 253, 0.28), transparent 32%),
    radial-gradient(circle at top right, rgba(187, 247, 208, 0.28), transparent 30%),
    #f5f7fa;
  color: #1a1a2e;
}

.dict-top-nav {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 6px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dict-nav-link {
  text-decoration: none;
  color: #4b5563;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.dict-nav-link--active {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
  font-weight: 700;
}

.dict-hero {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 22px;
}

.dict-hero-inner {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.07);
}

.dict-eyebrow {
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.dict-hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.15;
  margin-bottom: 12px;
}

.dict-hero-subtitle {
  color: #64748b;
  max-width: 720px;
  line-height: 1.8;
  font-size: 1.02rem;
}

.dict-container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 36px;
}

.dict-search-card,
.dict-recommend-section,
.dict-recent-section,
.dict-category-section,
.dict-list-container,
.dict-detail-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.dict-search-card {
  padding: 20px;
  margin-bottom: 16px;
}

.dict-search-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 10px;
}

.dict-search-row {
  display: flex;
  gap: 10px;
}

.dict-search-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid #dbeafe;
  border-radius: 12px;
  outline: none;
  background: #ffffff;
}

.dict-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.dict-clear-btn {
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 700;
  cursor: pointer;
}

.dict-clear-btn:hover {
  background: #cbd5e1;
}

.dict-search-hint {
  color: #94a3b8;
  font-size: 0.88rem;
  margin-top: 10px;
  line-height: 1.6;
}

.dict-recommend-section {
  padding: 18px 20px;
  margin-bottom: 16px;
}

.dict-recent-section {
  padding: 18px 20px;
  margin-bottom: 16px;
}

.dict-recent-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dict-recent-term {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.dict-recent-term:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.dict-recent-clear-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.dict-recent-clear-btn:hover {
  color: #475569;
}

.dict-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dict-section-heading h2 {
  font-size: 1.05rem;
  color: #334155;
}

.dict-section-heading p {
  font-size: 0.88rem;
  color: #94a3b8;
}

.dict-quick-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dict-quick-term {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.dict-quick-term:hover {
  background: #dbeafe;
}

.dict-category-section {
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.dict-category-tab {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
}

.dict-category-tab.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.dict-status-row {
  margin: 8px 2px 14px;
}

.dict-result-meta {
  color: #64748b;
  font-size: 0.9rem;
}

.dict-content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 18px;
  align-items: start;
}

.dict-list-container {
  min-height: 360px;
  padding: 18px;
}

.dict-loading {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #94a3b8;
}

.dict-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: dictSpin 0.8s linear infinite;
}

@keyframes dictSpin {
  to { transform: rotate(360deg); }
}

.dict-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* ★ Day 25 下一輪 (2)(3) 重新設計：星星原本用絕對定位疊在卡片外面，
   跟徽章的相對位置沒辦法用純 CSS 精準控制（徽章寬度會因分類文字長短而變），
   也是造成上一輪對不齊 bug 的根源之一。改成讓「查看詳情」的可點擊區域
   從整顆 <button> 換成卡片本身（<article> 搭配鍵盤可操作屬性），
   星星就能真正跟標題、徽章排在同一個 flex 列裡，位置永遠準確、不用猜座標。 */
.dict-term-card {
  min-width: 0;
  text-align: left;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  font-family: inherit;
  display: flex;
  flex-direction: column;
}

.dict-term-card:hover,
.dict-term-card--active {
  border-color: #93c5fd;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.dict-term-card:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.dict-favorite-btn {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #cbd5e1;
  padding: 2px;
  flex-shrink: 0;
}

.dict-favorite-btn.active {
  color: #f59e0b;
}

.dict-term-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

/* ★ (2)：星星＋分類徽章群組在一起，星星在左、徽章在右，整組貼齊標題右側 */
.dict-term-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.dict-term-card h3 {
  color: #0f172a;
  font-size: 1.05rem;
  line-height: 1.4;
}

.dict-category-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 800;
}

.dict-category-badge--technical {
  background: #ecfdf5;
  color: #047857;
}

.dict-category-badge--fundamental {
  background: #fffbeb;
  color: #b45309;
}

.dict-category-badge--market {
  background: #eef2ff;
  color: #4338ca;
}

.dict-category-badge--industry {
  background: #fdf2f8;
  color: #be185d;
}

.dict-term-explain {
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.7;
}

.dict-dev-source {
  margin-top: 10px;
  color: #94a3b8;
  font-size: 0.75rem;
}

.dict-empty {
  text-align: center;
  color: #64748b;
  padding: 80px 20px;
}

.dict-empty-hint {
  color: #94a3b8;
  margin-top: 8px;
  font-size: 0.9rem;
}

.dict-detail-panel {
  position: sticky;
  top: 16px;
  padding: 18px;
  min-height: 360px;
}

.dict-detail-close {
  float: right;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
}

/* ★ (1)：詳細說明面板的星星，用跟關閉按鈕一樣的 float 排版，
   星星在 DOM 順序上排在關閉按鈕後面，float:right 疊加後會自然排在關閉按鈕左邊 */
.dict-favorite-btn--detail {
  position: static;
  float: right;
  width: 30px;
  height: 30px;
  margin-right: 8px;
  font-size: 1.4rem;
}

.dict-detail-placeholder {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: #94a3b8;
}

.dict-detail-placeholder-icon {
  font-size: 2rem;
}

.dict-detail-category {
  display: inline-flex;
  margin-bottom: 12px;
  color: #2563eb;
  background: #eff6ff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.dict-detail-title {
  clear: both;
  color: #0f172a;
  font-size: 1.45rem;
  margin-bottom: 12px;
  line-height: 1.35;
}

.dict-aliases {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.dict-aliases code {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px 7px;
  color: #334155;
}

.dict-detail-block {
  margin-top: 16px;
}

.dict-detail-block h3 {
  font-size: 0.95rem;
  color: #334155;
  margin-bottom: 8px;
}

.dict-detail-block p {
  color: #475569;
  line-height: 1.8;
  white-space: pre-line;
}

.dict-detail-howto {
  background: #f0f9ff;
  border-left: 4px solid #38bdf8;
  padding: 14px 16px;
  border-radius: 0 12px 12px 0;
}

.dict-detail-note {
  margin-top: 18px;
  color: #94a3b8;
  font-size: 0.82rem;
  line-height: 1.6;
}

.dict-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 30px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.86rem;
  line-height: 1.8;
}

.dict-footer-link {
  display: inline-block;
  margin-top: 6px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 900px) {
  .dict-content-layout {
    grid-template-columns: 1fr;
  }

  .dict-detail-panel {
    position: static;
  }

  .dict-cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .dict-top-nav {
    justify-content: center;
  }

  .dict-hero-inner {
    padding: 22px;
  }

  .dict-search-row {
    flex-direction: column;
  }

  .dict-clear-btn {
    padding: 12px 18px;
  }

  .dict-section-heading {
    flex-direction: column;
    gap: 4px;
  }

  .dict-category-tab {
    flex: 1 1 calc(50% - 8px);
  }
}

/* ══════════════════════════════════════════════════
   Day 24B polish：固定字典頁背景
   目的：避免搜尋或往下滑時，柔和背景看起來消失
   ══════════════════════════════════════════════════ */
body.dictionary-page {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 12%, rgba(147, 197, 253, 0.34), transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(187, 247, 208, 0.32), transparent 32%),
    radial-gradient(circle at 50% 85%, rgba(219, 234, 254, 0.22), transparent 42%),
    linear-gradient(135deg, #eaf6ff 0%, #f4fbf8 42%, #f6f8fb 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* 預設沒有選術語時，不顯示關閉 X */
.dict-detail-panel:not(.dict-detail-panel--open) .dict-detail-close {
  display: none;
}

/* 預設提示置中 */
.dict-detail-panel:not(.dict-detail-panel--open) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.dict-detail-panel:not(.dict-detail-panel--open) .dict-detail-content {
  width: 100%;
}

/* ══════════════════════════════════════════════════
   Mobile polish：手機版點擊術語後，詳細說明顯示在卡片列表上方
   ══════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .dict-detail-panel {
    order: -1;
  }

  .dict-detail-panel:not(.dict-detail-panel--open) {
    display: none;
  }

  .dict-list-container {
    min-height: 260px;
  }
}

@media (max-width: 560px) {
  body.dict-has-query .dict-recommend-section,
  body.dict-has-query .dict-recent-section {
    display: none !important;
  }
}

.dict-readable-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dict-readable-text p {
  margin: 0;
  color: #475569;
  line-height: 1.85;
}