:root {
  --color-dark-green: #537D5D;
  --color-med-green: #73946B;
  --color-light-green: #9EBC8A;
  --color-beige: #D2D0A0;
  --color-bg: #f9f9f2;
  /* 極淺米白背景，呼應文青風 */
  --font-main: 'Noto Sans TC', sans-serif;

  font-size: 18px;
  /* Increase base font size for better visibility */
  --container-max-width: 96%;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(83, 125, 93, 0.12);
  --radius: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --iva-radius: 16px;
  --iva-card-bg: #ffffff;
  --iva-text-dark: #2d3748;
  --iva-text-muted: #64748b;

  /* --- 名次色階（金／銀／銅／其他）---
     三處徽章共用：排名列表頁掛在區塊上緣的 .block-title、排名詳情頁與歷屆詳情頁
     右下角的獎項徽章。改色只需改這裡一處，暗色值定義在下方 html[data-theme="dark"]。

     ⚠️ 一律「亮色淺底深字／暗色深底亮字」，**不要改成飽和金屬色配白字**：
        #EAB308 金 + 白字只有 1.9:1、#94A3B8 銀 + 白字 2.3:1，
        而 1.35rem 粗體屬於大字、WCAG 需求是 3:1，兩者都不合格。
        色相要由底色承擔、對比要由文字承擔，同一個色值做不到兩件事。 */
  --tier-gold-bg: #fde047;
  --tier-gold-fg: #854d0e;
  --tier-silver-bg: #e2e8f0;
  --tier-silver-fg: #475569;
  --tier-bronze-bg: #ffedd5;
  --tier-bronze-fg: #9a3412;
  --tier-other-bg: #f1f5f9;
  --tier-other-fg: #475569;
}

/* 名次配色的共用 class（幾何樣式仍由各頁自己的 class 負責，這裡只管顏色） */
.tier-gold {
  background: var(--tier-gold-bg);
  color: var(--tier-gold-fg);
}

.tier-silver {
  background: var(--tier-silver-bg);
  color: var(--tier-silver-fg);
}

.tier-bronze {
  background: var(--tier-bronze-bg);
  color: var(--tier-bronze-fg);
}

.tier-other {
  background: var(--tier-other-bg);
  color: var(--tier-other-fg);
}

/* 姓名不中斷組塊 (No-Break Name Unit) */
.author-name-unit {
  display: inline-block;
  white-space: nowrap;
}

/* --- IVA Standard Components --- */
/* 2026-10-22：1. 標準卡片容器（.iva-card）與 4. 權限鎖定卡片（.iva-permission-lock）沒有任何頁面使用，已移除。 */

/* 2. 標準彈窗系統 */
.iva-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.iva-modal-card {
  background: white;
  padding: 2.5rem;
  border-radius: 20px;
  width: 95%;
  max-width: 550px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  animation: iva-pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* 卡片本身不超過畫面高度，長訊息由 .iva-modal-body 內部捲動 ——
     圖示、標題與按鈕永遠留在畫面上（ISSUES.md 第 66 項）。
     Admin 的說明彈窗原本是靠該頁自己的 .admin-help-* 做到這件事，
     那份頁內樣式在改用共用元件後已無必要。 */
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

@keyframes iva-pop-in {
  from {
    transform: scale(0.8);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.iva-modal-title {
  margin-bottom: 1.5rem;
  font-size: 1.6rem;
  color: var(--color-dark-green);
  font-weight: 700;
}

.iva-modal-body {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 2rem;
  white-space: pre-wrap;
  line-height: 1.6;

  /* 只有這一段會捲動；短訊息不受影響（flex 項目在內容不足時不會被撐開）。
     min-height: 0 是必要的 —— flex 子項的預設 min-height:auto 會讓
     overflow 失效，卡片被內容撐破，長訊息照樣把按鈕頂出畫面。 */
  overflow-y: auto;
  min-height: 0;
  /* 文字不要貼著捲軸。左右對稱是刻意的 —— 內文是置中的，
     只加右邊會讓整段文字看起來偏左。 */
  padding-right: 14px;
  padding-left: 14px;

  /* 捲軸配色（Firefox）。預設的淺色捲軸在深色卡片上是一條白棒子。 */
  scrollbar-width: thin;
  scrollbar-color: #c7d2c9 transparent;
}

/* 條列式說明用的靠左內文（IvaModal.ShowInfo 的 alignLeft，2026-10-20）。
   只動內文；圖示、標題與按鈕仍置中。 */
.iva-modal-body.iva-modal-body-left {
  text-align: left;
}

/* 捲軸配色（Chrome／Edge／Safari）。
   ⚠️ ::-webkit-scrollbar 不吃 scrollbar-color，兩套都要寫。 */
.iva-modal-body::-webkit-scrollbar {
  width: 8px;
}

.iva-modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.iva-modal-body::-webkit-scrollbar-thumb {
  background: #c7d2c9;
  border-radius: 4px;
}

.iva-modal-body::-webkit-scrollbar-thumb:hover {
  background: #a9b8ab;
}

/* 彈窗頂端的表情圖示。
   ⚠️ 這個 class 原本被使用（TranslationFileManager）卻**沒有任何 CSS**，
   所以圖示一直是跟內文一樣大。2026-09-07 補上定義。 */
.modal-icon-large {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 1rem;
}

/* 彈窗的深色模式。
   ⚠️ 這幾條原本寫在 TranslationFileManager.razor.css 裡 —— 那是 Blazor 的隔離樣式，
   只對那一頁生效，別的頁面用同一組 class 就會在深色模式變成白底黑字。
   2026-09-07 移到這裡，讓「全站元件的樣式住在全站樣式表」。見 ISSUES.md 第 66 項。 */
html[data-theme="dark"] .iva-modal-card {
  background: #1e2521;
  border: 1px solid #3a443d;
}

html[data-theme="dark"] .iva-modal-title {
  color: #7fb389;
}

html[data-theme="dark"] .iva-modal-body {
  color: #9aa89c;
  scrollbar-color: #4a564d transparent;
}

/* 深色卡片上的捲軸：不設的話 Chrome 會畫一條白色的（2026-09-10 實測回報）。 */
html[data-theme="dark"] .iva-modal-body::-webkit-scrollbar-thumb {
  background: #4a564d;
}

html[data-theme="dark"] .iva-modal-body::-webkit-scrollbar-thumb:hover {
  background: #5e6d61;
}

/* 3. 標準按鈕系列 */
.iva-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.iva-btn-primary {
  background: var(--color-dark-green);
  color: white;
}

.iva-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.iva-btn-outline {
  background: white;
  border: 1px solid var(--color-beige);
  color: var(--color-dark-green);
}

.iva-btn-outline:hover {
  background: var(--color-bg);
}

/* 危險操作（刪除、清除）用的確認鈕 —— 與 iva-btn 併用：class="iva-btn iva-btn-danger" */
.iva-btn-danger {
  background: #d9534f;
  color: white;
}

.iva-btn-danger:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

html[data-theme="dark"] .iva-btn-outline {
  background: #1e2521;
  border-color: #3a443d;
  color: #f3e9dc;
}

html[data-theme="dark"] .iva-btn-outline:hover {
  background: #2e3631;
}

/* 暗色下的危險確認鈕：2026-09-17 再調暗一階（ISSUES.md 第 121 項）。
   原本是 #c9524e，在深色卡片上仍然太跳 —— 它是「確認刪除」這種需要看清楚、
   但不該搶走整個彈窗注意力的按鈕。文字改用淺色維持對比。 */
html[data-theme="dark"] .iva-btn-danger {
  background: #a33f3c;
  color: #ffe9e8;
}

html[data-theme="dark"] .iva-btn-danger:hover {
  background: #b84a46;
}

/* 5. 標準 Toast 通知 */
.toast-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(83, 125, 93, 0.98);
  color: white;
  padding: 1.2rem 2.5rem;
  border-radius: 12px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
  z-index: 10001;
  font-weight: 500;
  pointer-events: none;
  animation: iva-toast-fade 2.5s ease-in-out forwards;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
}

@keyframes iva-toast-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%);
  }

  10% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }

  90% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
}


body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-dark-green);
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Global Form Styles --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
textarea,
select {
  /* Added select here */
  padding: 0.8rem;
  border: 1px solid var(--color-beige);
  border-radius: 4px;
  font-family: var(--font-main);
  /* Ensure font matches */
  font-size: 1rem;
  color: var(--color-dark-green);
  background-color: white;
  transition: var(--transition);
  width: 100%;
}

/* iPhone Safari 的日期欄位自帶原生最小寬度，會蓋過 width:100%、凸出外框；
   取消原生外觀並允許縮小。iOS 預設日期置中，改靠左與其他欄位一致；
   空值時內容會塌掉，給文字區保底高度。全站日期欄位一體適用（2026-10-20） */
input[type="date"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.5em;
}

input:focus,
textarea:focus,
select:focus {
  /* Added select here */
  outline: none;
  border-color: var(--color-med-green);
  box-shadow: 0 0 0 3px rgba(115, 148, 107, 0.1);
}

/* Custom select arrow styling if needed, or keep browser default for accessibility */
select {
  cursor: pointer;
  appearance: none;
  /* Remove default arrow */
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2373946B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
  padding-right: 2.5rem;
  /* Make room for arrow */
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.2rem;
}

.form-group label {
  font-size: 0.95rem;
  color: #555;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
}

.home-container,
.admin-container,
.upload-container,
.maintenance-container,
.review-container,
.translation-container {
  width: 98%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 1rem 4rem 1rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: opacity, transform;
  background-color: transparent;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Prevent focus outline on navigation targets */
h1:focus,
.page-header:focus,
.admin-container:focus,
.home-container:focus {
  outline: none;
}

/* --- Navbar Styles（舊版，已移除）---
   2026-10-22 整段刪除：navbar、navbar-container、nav-logo、nav-link、dropdown-menu、
   dropdown-item、navbar-left/center/right、lang-toggle-btn、logout-btn 等。
   現在的導覽列在 Layout/NavBar.razor，用的全是 iva- 開頭的 class（樣式也寫在那支檔案裡）。
   ⚠️ 搜尋「有沒有人用」時要精確比對整個 class 名稱 —— 用 \b 的話 `iva-nav-link`
      也會被當成 `nav-link`，這一段就曾因此被誤判成「仍在使用」。 */

/* slideDown 還有別的規則在用，留著 */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Common UI Components --- */
.page-header {
  text-align: center;
  margin: 3.5rem 0;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-light-green);
}

.title {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  color: var(--color-dark-green);
  letter-spacing: 0.3rem;
  font-weight: 300;
  margin: 0;
}

/* --- Home Page --- */
.player-section {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 3.5rem auto;
  background-color: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(83, 125, 93, 0.05);
}

/* 核心修正：當公告模式時，強制全綠且高度自適應 */
.player-section.hero-mode {
  background-color: #537D5D !important;
  height: auto !important;
  min-height: 400px;
  overflow: visible !important;
  display: block !important;
  /* 確保內容能自然撐開 */
}

.player-section.hero-mode .placeholder-hero {
  background-color: transparent !important;
  /* 內部透明，由外層顯色 */
  height: auto !important;
  padding: 4rem 2rem;
}

.active-player-container {
  display: flex;
  min-height: 520px;
}

.video-wrapper {
  flex: 2.5;
  background: #000;
  aspect-ratio: 16 / 9;
}

.main-video-player {
  width: 100%;
  height: 100%;
  border: none;
}

.no-video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  background: #111;
  font-size: 1.2rem;
}

.no-video-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.active-work-details {
  flex: 1;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  background: white;
  border-left: 1px solid var(--color-beige);
}

.detail-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.detail-code {
  font-size: 0.85rem;
  color: var(--color-med-green);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.detail-title {
  font-size: 1.8rem;
  margin: 0.4rem 0;
  /* 詳情頁標題＝中性主要文字色，**亮暗兩個模式都由這一行決定**
     （--iva-text-dark 亮色是 #2d3748、暗色是 #f3e9dc）。

     規則：列表頁的標題用主題色做識別，詳情頁的標題用中性色做閱讀 ——
     詳情頁只有一個標題，它是主角，而該頁的強調色已經給了作品編號與
     組長／組員標籤，標題再上色會讓強調過多、層次塌掉。

     ⚠️ 不要改回 var(--color-dark-green)：那會讓標題在亮色是主題色、
        暗色是中性色，切換主題時角色就變了。 */
  color: var(--iva-text-dark);
  line-height: 1.2;
}

.detail-author {
  font-size: 1rem;
  color: #777;
}

/* label-value 的層級：**色彩負責當欄位路標、對比負責承載內容**，兩種訊號各司其職。

   組長／組員／指導老師的標籤（`<strong>`）由各頁上主題色，但**不要粗體** ——
   標籤是鷹架，又粗又上色等於雙重強調，會把鷹架強調得比內容還重。
   用 500 而非 400：1.5rem 的字級完全不加重會顯得軟。

   名字則走中性主要文字色，**這一行同時管亮暗兩個模式**
   （--iva-text-dark 亮色 #2d3748、暗色 #f3e9dc），所以四個詳情頁裡原本的
   author-name-unit 暗色覆寫都已刪除。能用 token 表達的角色就不要寫兩套寫死色。 */
.detail-author strong {
  font-weight: 500;
}

.detail-author .author-name-unit {
  color: var(--iva-text-dark);
}

/* 列表卡片的標籤同樣去粗體（原本是灰色 + 粗體，那個粗體加在次要色上也不合理）。
   ⚠️ 卡片的**名字刻意不跟著改成深黑** —— 一頁十幾張卡，名字全部加深會讓整頁
      重心下沉、把卡片標題壓過去。卡片那一區整體壓低是對的。 */
.work-team strong {
  font-weight: 500;
}

.close-player-btn {
  background: transparent;
  border: 1px solid var(--color-beige);
  color: var(--color-med-green);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-player-btn:hover {
  background: var(--color-med-green);
  color: white;
  transform: rotate(90deg);
}

.detail-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
  gap: 1rem;
}

/* 歷屆詳情頁底部的說明文字（2026-09-24，ISSUES.md 第 156 項）。
   佔的是投票牆詳情頁「按讚鈕」的位置，所以要低調 —— 它是說明，不是動作。 */
.view-only-note {
  color: #8a8a8a;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}
html[data-theme="dark"] .view-only-note { color: #9aa39c; }

.like-counter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.count-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-dark-green);
}

.like-button {
  background-color: var(--color-light-green);
  color: white;
  border: none;
  padding: 0.7rem 1.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(158, 188, 138, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.like-button:hover:not(:disabled) {
  background-color: var(--color-med-green);
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(115, 148, 107, 0.4);
}

.like-button:active:not(:disabled) {
  transform: translateY(-1px);
}

.like-button.disabled {
  background-color: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

.large-btn {
  font-size: 1.1rem;
  padding: 0.9rem 2.2rem;
}

.placeholder-hero {
  width: 100%;
  height: auto !important;
  aspect-ratio: auto !important;
  min-height: 450px;
  background-image: url('https://images.unsplash.com/photo-1516541196182-6bdb0516ed27?auto=format&fit=crop&q=80') !important;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.placeholder-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(83, 125, 93, 0.85), rgba(115, 148, 107, 0.65)) !important;
  z-index: 1;
}

/* 2026-10-22：原本這裡有兩條 .hero-content，第二條把第一條的屬性全部重寫，
   第一條的 padding: 3rem 2rem 從來沒生效過，已併成一條。 */
.hero-content {
  position: relative;
  z-index: 2;
  /* 確保文字在漸層遮罩上方 */
  text-align: center;
  color: white;
  padding: 2.5rem;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  max-width: 1000px;
}

.hero-content h2 {
  font-size: clamp(2.2rem, 7vw, 3.5rem);
  margin-bottom: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.hero-content p {
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  line-height: 1.8;
  opacity: 0.95;
  font-weight: 400;
}

/* --- Filter & Search --- */
.filter-bar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.filter-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-bar button {
  background: white;
  border: 1px solid var(--color-beige);
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  /* Match nav link size */
  font-weight: 600;
  /* Match nav link weight */
  transition: var(--transition);
  color: var(--color-med-green);
}

.filter-bar button:hover {
  background: #f0f0eb;
}

.filter-bar button.active {
  background: var(--color-med-green);
  color: white;
  border-color: var(--color-med-green);
  box-shadow: 0 4px 8px rgba(115, 148, 107, 0.2);
}

.search-box-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 400px;
  min-width: 280px;
  position: relative !important;
  /* 強制相對定位，確保內部按鈕基準正確 */
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.8rem 0.75rem 1.5rem !important;
  /* 確保右側留夠空間，左側稍微加寬 */
  border: 1px solid var(--color-beige);
  border-radius: 40px;
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
  /* 確保 padding 不會撐破寬度 */
}

.clear-search-btn {
  position: absolute;
  right: 12px !important;
  /* 固定在右側內部 */
  background: #f1f5f9;
  border: none;
  color: #64748b;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
  padding: 0;
}

.clear-search-btn:hover {
  background: #e2e8f0;
  color: #ef4444;
  transform: scale(1.1);
}

.clear-search-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5px;
  /* 加粗圖示線條 */
}

/* --- Work Grid --- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2.5rem;
}

.work-card {
  position: relative;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 1;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.6s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.6s;
  isolation: isolate;
  backface-visibility: hidden;
  border: 1px solid transparent;
}

/* 虛擬連結層：鋪滿全卡片並確保高於圖片但低於按鈕 */
.card-link-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  text-decoration: none;
}

.work-card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-light-green);
}

.thumbnail-container {
  aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #537D5D 0%, #2d3748 100%); /* IVA 專屬漸層保底 */
  border-top-left-radius: var(--iva-radius);
  border-top-right-radius: var(--iva-radius);
}

.thumbnail-container::before {
  content: "IVA";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.1);
  letter-spacing: 0.5rem;
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  display: block;
  position: relative;
  z-index: 2;
  opacity: 0; /* 預設隱藏，載入成功後再顯示 */
}

.thumbnail.loaded {
  opacity: 1;
}

.thumbnail-img-fallback {
  background: linear-gradient(135deg, #73946B 0%, #537D5D 100%) !important;
}

.work-card:hover .thumbnail {
  transform: scale(1.04);
}

.work-info {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.work-title {
  font-size: 1.1rem;
  margin: 0 0 1.2rem 0;
  color: var(--color-dark-green);
  line-height: 1.5;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.like-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.like-count {
  font-size: 0.95rem;
  color: var(--color-med-green);
  font-weight: 600;
}

.share-btn {
  position: relative;
  z-index: 10;
  /* 高於 .card-link-overlay */
  transition: all 0.2s;
}

.share-btn:hover {
  transform: scale(1.1);
  color: var(--color-dark-green) !important;
}

.like-section {
  position: relative;
  z-index: 10;
  /* 高於 .card-link-overlay */
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.small-btn {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
}

/* --- Admin Page --- */
.admin-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--color-light-green);
  padding-bottom: 0;
}

/* 2026-10-22 這一區清掉沒人用的舊數據管理頁 class：admin-tab-btn、control-panel（含 .in-grid 系列）、
   control-panel-mobile、control-grid、popular-box／top-list／top-item、rank-badge、rank-1～3、
   top-title、top-likes、emergency-btn。 */

.admin-content-section {
  display: block;
  /* Default display */
  animation: fadeIn 0.3s ease;
}

/* Default Visibility (Mobile First approach) */
.mobile-hidden {
  display: none !important;
}

.control-panel-desktop {
  display: none !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.stat-box {
  background: white;
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-beige);
  text-align: center;
  box-shadow: var(--shadow-sm);
  height: 100%;
  /* Ensure full height in grid */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.big-number {
  font-size: 2.8rem;
  font-weight: 700;
  margin: 0.5rem 0;
  color: var(--color-dark-green);
}

.update-time {
  font-size: 0.8rem;
  color: #aaa;
  margin-top: 0.5rem;
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.panel-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-dark-green);
}

.confirm-settings-btn {
  background: var(--color-dark-green);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  text-align: center;
  padding: 0 !important;
  display: inline-block;
  vertical-align: middle;
}

.confirm-settings-btn:hover {
  background: #3e6146;
  transform: translateY(-2px);
}

.confirm-settings-btn:active {
  transform: translateY(0);
}

/* --- Upload Page --- */
/* 2026-10-22 清掉舊上傳頁留下、全專案已無人使用的 class（作者／集數欄位、分頁鈕、
   自製檔案按鈕、toast 通知等）。這一段剩下的都是投稿頁與其他頁仍在用的。 */
.upload-layout {
  display: grid;
  gap: 3rem;
  align-items: start;
}

.upload-card {
  background: white;
  padding: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-beige);
  box-shadow: var(--shadow-md);
}

.preview-btn {
  background: transparent;
  color: var(--color-med-green);
  border: 1px solid var(--color-light-green);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
  font-weight: 500;
  text-decoration: none;
  /* Remove underline */
}

.preview-btn:hover {
  background-color: #f0f7f0;
  color: var(--color-dark-green);
}

.form-row {
  display: flex;
  gap: 1.5rem;
}

.form-row .form-group {
  flex: 1;
}

/*
 * 這裡原本有一條全域 `.file-name`，帶 `max-width: 200px`（ISSUES.md 第 2 項）。
 * 2026-09-04 移除，樣式改放進 Pages/DataUpload.razor.css（scoped，唯一的使用者）。
 *
 * 為什麼要移除：`file-name` 是極容易撞名的 class。任何頁面只要寫了
 * class="file-name"，檔名就會被無聲地鎖在 200px 內截斷成「…」，
 * 而且在頁面自己的 <style> 覆寫了 white-space / overflow 之後「看起來像修好了」，
 * 實際上 max-width 還鎖著 —— HomeContentManager 就踩過，查了三輪才找到原因
 * （該頁最後改名成 .download-file-name 避開）。
 *
 * ⚠️ 請不要在這個全域樣式表裡放語意寬泛的 class 名稱（.file-name、.title、.card…）。
 *    需要共用時請用具體前綴，或改放進該頁的 .razor.css（scoped，不會外洩）。
 */

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #444;
  opacity: 0.5;
}

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
  color: #ccc;
  font-size: 0.85rem;
  font-weight: 500;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: #eee;
  margin: 0 1rem;
}

.upload-form-section .form-group label {
  font-size: 1.15rem;
  margin-bottom: 0.8rem;
  font-weight: 600;
  color: var(--color-dark-green);
}

.drop-zone {
  border: 2px dashed var(--color-med-green);
  border-radius: 10px;
  padding: 3rem;
  text-align: center;
  background: #f9faf9;
  cursor: pointer;
  transition: var(--transition);
}

.drop-zone:hover {
  background: #f0f7f0;
  border-color: var(--color-dark-green);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--color-med-green);
}

.preview-card {
  background: white;
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-beige);
  position: sticky;
  top: 110px;
  box-shadow: var(--shadow-lg);
}

.preview-frame {
  width: 100%;
  height: 700px;
  border: none;
  background: white;
}

.preview-frame {
  width: 100%;
  height: 700px;
  border: none;
  background: white;
}

.submit-btn {
  margin-top: 1rem;
  background: var(--color-dark-green);
  color: white;
  border: none;
  padding: 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  transition: var(--transition);
  width: 100%;
  box-shadow: 0 4px 15px rgba(83, 125, 93, 0.3);
}

/* ⚠️ `:not(:disabled)` 不能拿掉（2026-10-02）。
   CSS 的 `:hover` **對 disabled 的按鈕照樣生效** —— 少了這個條件，
   停用中的送出鈕滑過去一樣會變深、往上浮 2px、陰影加大，
   三個訊號都在說「我可以按」，按下去卻什麼都不會發生。
   投稿頁的送出鈕有兩種停用情形（投稿時段外、表單還沒填完），兩種都會撞到。

   📌 寫成條件式選取器，而不是另外補一條 `.submit-btn:disabled:hover` 去覆寫 ——
      覆寫版要把 background / transform / box-shadow 三個值各寫一次反解，
      日後這裡多加一個效果就會漏掉那一個。 */
.submit-btn:not(:disabled):hover {
  background: #3e6146;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(83, 125, 93, 0.4);
}

/* 停用狀態：拿掉陰影，連「靜態的浮起感」也不要留。
   ⚠️ 這裡只能處理 .submit-btn 自己宣告的那層陰影。投稿頁的送出鈕在
      inline style 另外寫了一層更濃的 box-shadow，inline 的優先序高於這裡，
      必須在 Upload.razor 那邊依狀態拿掉（游標同理）。 */
.submit-btn:disabled {
  box-shadow: none;
  cursor: not-allowed;
}

#blazor-error-ui {
  background: lightyellow;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.login-card {
  background: white;
  padding: 4rem 3rem;
  border-radius: 16px;
  border: 1px solid var(--color-beige);
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-title {
  color: var(--color-dark-green);
  margin-bottom: 0.8rem;
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: 2px;
}

.login-subtitle {
  color: #888;
  margin-bottom: 2.5rem;
  font-size: 1rem;
}

.login-btn {
  width: 100%;
  background: var(--color-dark-green);
  color: white;
  border: none;
  padding: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  transition: var(--transition);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(83, 125, 93, 0.2);
}

/* --- Maintenance --- */
.maintenance-card {
  background: white;
  padding: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-beige);
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
}


/* --- Responsive Modal System (Shared across pages) --- */
/* 2026-10-22 舊彈窗外框（custom-modal-overlay／card、responsive-modal、modal-confirm-btn、
   close-modal-x、popInModal）已移除 —— 彈窗都改用 IvaModal（.iva-modal-*）。
   下面幾條同名 Bootstrap 的 modal-* 先不動（屬 Bootstrap 同名，另案判斷）。 */
.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    line-height: 1;
}

.modal-title {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    font-weight: 800;
    color: #333;
}

.modal-body {
    font-size: 1.25rem;
    color: #444;
    margin-bottom: 2.5rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
}

@media (max-width: 600px) {
    .modal-icon {
        font-size: 3rem;
    }
    .modal-title {
        font-size: 1.4rem;
    }
    .modal-actions {
        flex-direction: column;
    }
}

/* 2026-09-08：這裡原本有兩行沒有選擇器的孤兒宣告 —— `align-items: flex-end;` 加一個 `}`。
   瀏覽器的 CSS 剖析器遇到它會進入錯誤復原、跳過到下一個 `}`，所以沒有實際效果
   （後面的 .checkbox-wrapper 不受影響），但它代表**某條規則的選擇器在某次編輯時被刪掉了**。
   已無從得知原本是哪個選擇器，故直接移除這段無效內容。見 ISSUES.md 第 46 項。 */

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  height: 50px;
}

.checkbox-input {
  width: 20px !important;
  height: 20px !important;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 1.2rem;
  margin-top: 2rem;
}

.action-row-center {
  justify-content: center;
  margin-top: 3rem;
}

.save-btn {
  background: var(--color-dark-green);
  color: white;
  border: none;
  padding: 0.8rem 2.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(83, 125, 93, 0.2);
}

.clear-btn {
  background: #f0f0f0;
  color: #666;
  border: none;
  padding: 0.8rem 2rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.data-table th,
.data-table td {
  padding: 1.2rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

.data-table th {
  background: #fbfbf7;
  font-size: 0.9rem;
  color: #666;
  font-weight: 600;
}

.action-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.edit-btn {
  background: #e3f2fd;
  color: #1976d2;
}

.edit-btn:hover {
  background: #bbdefb;
}

.delete-btn {
  background: #ffebee;
  color: #d32f2f;
}

.delete-btn:hover {
  background: #ffcdd2;
}

.status-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  /* ⚠️ 2026-10-13 補上。徽章是圓角膠囊，裡面的字一旦換行就會被撐成
     上下兩行、圓角扭曲，看起來像壞掉（「審核通過」在 /review 的結果欄
     被斷成「審核通」「過」）。
     徽章的文字本來就是短標籤，不換行是它該有的行為；
     真的放不下時應該是把欄位加寬，不是讓它斷行。 */
  white-space: nowrap;
}

.status-yes {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-no {
  background: #f5f5f5;
  color: #9e9e9e;
}

/* --- Footer --- */
.footer {
  /* 版型：橫向細長列，內容靠右（顏色維持原本配色） */
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  text-align: right;
  padding: 1.75rem 2.5rem;
  background: rgba(210, 208, 160, 0.1);
  border-top: 1px solid var(--color-beige);
  margin-top: auto;
  color: #73946B;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* 手機版：留白縮小，避免細長列被文字擠爆 */
@media (max-width: 575.98px) {
  .footer {
    padding: 1.25rem 1.25rem;
    font-size: 0.82rem;
  }
}

/* --- 頁尾貼齊視窗底部 (sticky footer) ---
   只作用於「直接包含 .footer」的頁面容器（首頁、入圍名單…），
   讓內容不足時頁尾仍落在視窗最下方，且與上方影片卡片保留間距。 */
.main-content-wrapper:has(> div > .footer) {
  display: flex;
  flex-direction: column;
  /* 頁尾滿版溢出容器時不要產生橫向捲軸（clip 仍允許 navbar sticky） */
  overflow-x: clip !important;
}

.main-content-wrapper > div:has(> .footer) {
  display: flex;
  flex-direction: column;
  flex: 1;
  /* 原本容器底部的 4rem 留白改移到頁尾上方，避免頁尾下方多出空白 */
  padding-bottom: 0;
}

/* 頁尾滿版：掙脫頁面容器（98% + 左右 1rem 留白）的寬度限制，橫跨整個螢幕 */
.main-content-wrapper > div:has(> .footer) > .footer {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

/* 頁尾正上方的區塊（作品清單 / 空狀態）與頁尾保持間距，不緊貼卡片 */
.main-content-wrapper > div:has(> .footer) > *:nth-last-child(2) {
  margin-bottom: 4rem;
}

/* Like Query Styles */
.like-query-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-beige);
  box-shadow: var(--shadow-md);
  margin-bottom: 2.5rem;
  display: flex;
  flex-direction: column;
  height: 70vh !important;
  /* Force responsive height */
  min-height: 400px;
  overflow: hidden;
}

.compact-search {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.like-query-content {
  flex: 1 1 0;
  display: flex;
  gap: 1rem;
  overflow: hidden;
  position: relative;
  min-height: 0;
  padding-bottom: 5px;
  height: 100%;
  /* Restore height */
}

.works-list-compact {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #eee;
  border-radius: 4px;
  min-height: 0;
  max-height: 100%;
}

/* 精簡表格（數據管理按讚查詢、權限管理人員清單）。
   2026-10-22 由兩套合成一條：數值照合併前實際生效的組合寫（字級／留白／格線取後寫的那套，
   表頭固定、淺灰底、最小寬度取先寫的那套），外觀不變。不要在別處再寫一份 .compact-table。 */
.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 400px;
  /* Ensure minimum width to prevent squishing */
}

.compact-table th,
.compact-table td {
  padding: 0.8rem;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
}

.compact-table th {
  background: #f9f9f9;
  position: sticky;
  top: 0;
  z-index: 1;
}

.compact-table tr.selected {
  background: #f0f7f0;
}

.like-details-panel {
  flex: 1;
  background: #fafafa;
  border: 1px solid #ccc;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 10px;
  height: calc(100% - 15px);
  /* Fix clipping by subtracting margin */
}

.records-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  width: 100%;
  height: 100%;
  /* Restore height to fix scrollbar */
}

.details-header {
  padding: 0.8rem;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0f0f0;
}

.details-header h4 {
  margin: 0;
  font-size: 0.95rem;
}

.records-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  width: 100%;
  height: 100%;
  background: white;
  /* White content area inside gray frame */
  border: 1px solid #ddd;
  /* Inner border for the list */
}

/* --- RWD --- */
@media (min-width: 1400px) {

  .home-container,
  .upload-container,
  .admin-container,
  .review-container {
    max-width: 98%;
  }

  /* Admin Grid Layout for Large Screens */
  .admin-container {
    max-width: 98%;
    display: block;
  }

  .admin-container>.page-header {
    margin-bottom: 1.5rem;
  }

  .stats-grid.top-metrics {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    /* Force 5 columns for new layout */
    gap: 1.5rem;
    margin-bottom: 2rem;
  }

  /* Merge Control Panel into Grid */
  .control-panel-desktop {
    display: block !important;
  }

  /* Restore stats grid on desktop even if hidden by mobile logic */
  .mobile-hidden {
    display: grid !important;
  }

  /* Hide tabs on desktop */
  .admin-tabs {
    display: none !important;
  }

  /* Show all content sections on desktop by default */
  .admin-content-section {
    display: block !important;
  }

  /* Specific layout for the 2-column bottom section */
  .admin-bottom-layout {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 1.5rem;
    align-items: start;
    margin-bottom: 2.5rem;
  }
}

@media (max-width: 1399.98px) {

  /* Show tabs on smaller screens */
  .admin-tabs {
    display: flex !important;
  }

  /* Hide desktop merged panel */
  .control-panel-desktop {
    display: none !important;
  }

  /* Content visibility controlled by tabs/Blazor logic, 
       but we ensure the container itself is flexible */
  .admin-bottom-layout {
    display: block;
  }

  .like-query-card {
    margin-bottom: 2rem;
    height: 80vh;
    /* More height on mobile */
  }
}

@media (max-width: 1024px) {
  .upload-layout {
    grid-template-columns: 1fr;
  }

  .preview-card {
    position: static;
    margin-top: 2rem;
  }

  .active-player-container {
    flex-direction: column;
    min-height: auto;
  }

  .active-work-details {
    border-left: none;
    border-top: 1px solid var(--color-beige);
  }
}

@media (max-width: 768px) {
  .filter-bar-container {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box-wrapper {
    max-width: none;
  }

  .title {
    font-size: 2rem;
  }

  .detail-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .detail-actions {
    flex-direction: column;
    gap: 1.2rem;
    align-items: stretch;
  }

  .like-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .save-btn,
  .clear-btn {
    width: 100%;
  }
}

/* --- Document Review Page --- */
.compact-header {
  margin: 2rem 0;
  padding-bottom: 1rem;
  border-bottom: none;
}

.review-table-section {
  background: white;
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  border: 1px solid var(--color-beige);
}

.table-responsive {
  overflow-x: auto;
}

.review-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1200px;
}

.review-table th,
.review-table td {
  padding: 1rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
  white-space: nowrap;
}

.review-table th {
  background: #fbfbf7;
  color: #666;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.review-table tr:hover {
  background-color: #f9f9f7;
}

.review-table tr.selected-row {
  background-color: #f0f7f0;
}

.icon-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #eee;
  transform: scale(1.1);
}

.query-btn.active {
  background: var(--color-med-green);
  border-color: var(--color-med-green);
  color: white;
}

.status-badge.status-pending {
  background: #fff3e0;
  color: #e65100;
}

.limit-text {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-left {
  text-align: left !important;
}

.text-small {
  font-size: 0.8rem !important;
  color: #888;
}

.font-bold {
  font-weight: 700;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.pagination button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-beige);
  background: white;
  border-radius: 4px;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Review Details Section */
.review-details-section {
  animation: slideDown 0.3s ease;
}

/* 2026-10-05（ISSUES 第 168 項）：改成兩列。
     第 1 列 ── 成員名冊（.members-card）跨滿兩欄
     第 2 列 ── 左：檔案清單（450px）／右：檔案檢視

   原本成員卡片與檔案清單疊在 .left-column（450px）、檔案檢視獨佔右欄一路拉到底，
   於是七欄的成員表格擠在 450px 裡，而右側上半部是一大塊空白。 */
/* 2026-10-13：第 2 列改成左右對半。
     原本是 `450px 1fr` —— 左邊是窄窄的檔案清單、右邊是檔案檢視。
     那張檔案清單卡已經整個併進「審核項目」（每一列多一顆 👁 檢視鈕），
     而審核項目要放下「項目 / 結果 / 檢視 / 審核」四欄，450px 不夠。

   ⚠️ 兩邊都用 fr，不要把任何一邊寫成固定 px ——
      固定的那一邊在大螢幕上不會跟著成長，另一邊則會爆長到用不完。 */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: start;
}

.details-grid > .members-card {
  grid-column: 1 / -1;
}

/* 📌 .left-column / .right-column 的規則 2026-10-05 一併移除。
   那兩個包裝層已從 Review.razor 拿掉（卡片現在是 .details-grid 的直接子元素），
   而全專案搜尋後確認沒有別的地方用它們。
   （AnnouncementPanel 用的是 .hero-left-column，不同的 class。） */

.detail-card {
  background: white;
  border: 1px solid var(--color-beige);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: var(--color-dark-green);
  border-left: 4px solid var(--color-med-green);
  padding-left: 0.8rem;
}

.work-header-info h4 {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
}

.members-table {
  width: 100%;
  border-collapse: collapse;
}

.members-table th,
.members-table td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.members-table th {
  background: #fbfbf7;
  font-weight: 600;
  color: #666;
}

/* Preview Panel */
.preview-panel {
  background: white;
  border: 1px solid var(--color-beige);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.preview-header {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: #555;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.8rem;
}

.preview-content-box {
  /* 深色底是給**影片與圖片**用的：留白的地方該是暗的，才看得出畫面邊界。 */
  background: #222;
  flex-grow: 1;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  overflow: hidden;
}

/* 文件（PDF / 純文字 / 不能預覽的下載卡）改成白底 —— 它們是「一張紙」，
   不是一段影片。2026-10-05：.txt 在深色底上會變成深底淺字，幾乎讀不了。 */
.preview-content-box.is-document {
  background: #fff;
}

.preview-frame-large {
  width: 100%;
  height: 100%;
  min-height: 600px;
  border: none;

  /* ⚠️ 這兩行是 2026-10-05 修 .txt 預覽背景變黑的關鍵（ISSUES.md 第 172 項）。
     純文字檔沒有自己的樣式，是**瀏覽器**用預設樣式表畫的；
     而 Chrome 會讓 text/plain 文件跟著使用者的系統深色設定走 ——
     於是同一個檔案，有人看到白底黑字、有人看到黑底白字，和我們的頁面主題無關。

     `color-scheme: light` 告訴瀏覽器「這個內嵌文件請用淺色畫」，
     `background` 則是在文件本身透明時墊底。少了前者，光補背景色沒有用：
     文字仍然是為深色底準備的淺色，白底淺字一樣看不見。 */
  color-scheme: light;
  background: #fff;
}

.preview-image-large {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.preview-placeholder-large {
  color: #666;
  font-size: 1.2rem;
}

@media (max-width: 1024px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Work Detail Page (Standalone) --- */
.work-detail-page {
  width: 100%;
  min-height: 100vh;
  padding: 3rem;
  /* Increased padding */
  background-color: var(--color-bg);
  /* Use original beige background */
  display: flex;
  align-items: center;
  justify-content: center;
}

.work-detail-page .active-player-container {
  width: 98%;
  /* Increased width */
  max-width: 1800px;
  /* Increased max-width */
  min-height: 700px;
  /* Increased min-height for more impact */
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: 0 auto;
}

/* Adjust close button for standalone page */
.work-detail-page .close-player-btn {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

/* Ensure the video wrapper takes appropriate height in full page mode */
.work-detail-page .video-wrapper {
  aspect-ratio: 16 / 9;
  background: #000;
}

@media (max-width: 768px) {
  .work-detail-page {
    padding: 0;
    background: white;
    align-items: flex-start;
  }

  .work-detail-page .active-player-container {
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
  }
}

/* --- Permission Management Specific --- */
.perm-layout {
  display: flex;
  flex-direction: column;
  /* 改為垂直排列 (上下) */
  gap: 0;
  min-height: 500px;
  margin-top: 1rem;
}

.perm-side-nav {
  flex: 0 0 auto;
  /* 高度自動 */
  display: flex;
  flex-direction: row;
  /* 改為水平排列 */
  gap: 4px;
  padding-top: 0;
  border-bottom: 1px solid var(--color-beige);
  /* 底部增加線條作為基準 */
  margin-bottom: -1px;
  /* 讓分頁蓋住線條 */
  z-index: 2;
  /* 確保分頁在最上層 */
  padding-left: 1rem;
  /* 左側留點空隙 */
}

.bookmark-tab {
  padding: 0.6rem 1.2rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px 8px 0 0;
  /* 改為上方圓角 */
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  font-weight: 500;
  color: #666;
  border-bottom: none;
  font-size: 0.95rem;
  margin-right: 2px;
}

.bookmark-tab:hover {
  background: #f0f7f0;
  color: var(--color-med-green);
}

.bookmark-tab.is-active {
  background: white;
  color: var(--color-dark-green);
  border: 1px solid var(--color-beige);
  /* 增加邊框 */
  border-bottom: 1px solid white;
  /* 蓋住底部線條，形成融合效果 */
  font-weight: 700;
  margin-bottom: -1px;
  /* 向下延伸蓋住線條 */
  padding-top: 0.5rem;
  /* 微調高度平衡 */
  padding-bottom: 0.7rem;
}

.perm-main-panel {
  flex: 1;
  background: white;
  border: 1px solid var(--color-beige);
  border-top: none;
  /* 移除上方邊框，由分頁列取代 */
  border-radius: 0 0 8px 8px;
  /* 只保留下方圓角 */
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  z-index: 1;
}

/* 2026-10-22 清掉舊權限頁沒人用的 class：mini-btn、tab-header、drawer-info、perm-tag、
   grade-*、perm-badge、item-*、check-item、perm-group-card／header／body、perm-checkbox-item、
   change-summary-box、assign-header、summary-box、assign-actions、slide-sidebar、warning-text。
   這一區剩下的（perm-layout、bookmark-tab、drawer-*、query-split-layout…）都還在用。 */

/* .view-toggles／.toggle-btn 只留一套：見下方「Toggle & Switch Components」。
   2026-10-22 刪掉這裡的舊版（米灰底那套）—— 它大多被後面的 !important 蓋掉，
   只剩 `:hover:not(.active)` 那條因為權重較高還在生效，曾讓稽核日誌選取中的按鈕滑過去整顆變白。 */

.perm-container-wrapper {
  margin-top: 1.5rem;
  animation: fadeIn 0.4s ease;
}


.perm-tab-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.table-container {
  flex: 1;
  overflow-y: auto;
  margin-top: 1.5rem;
  border: 1px solid #eee;
  border-radius: 8px;
}

/* 雙欄切換版面 */
.query-split-layout {
  display: flex;
  gap: 1.5rem;
  flex: 1;
  overflow: hidden;
  margin-top: 1.5rem;
}

.user-list-side {
  flex: 0 0 320px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
}

.user-detail-side {
  flex: 1;
  overflow-y: auto;
  background: #fcfcf9;
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid #f0f0e0;
}

/* 抽屜側欄 */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 3000;
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: 450px;
  /* Slightly wider for better table display */
  height: 100%;
  background: white;
  padding: 0;
  /* Remove default padding to let header stretch */
  box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
  animation: slideInRight 0.3s ease;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: 1.5rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h4 {
  margin: 0;
  color: #537D5D;
  font-size: 1.2rem;
  font-weight: 700;
}

.drawer-header button {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: #999;
  cursor: pointer;
  transition: color 0.2s;
}

.drawer-header button:hover {
  color: #333;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* 抽屜底部固定按鈕列：名單過長時內容在 .drawer-body 捲動，這一列仍固定在底部 */
.drawer-footer {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

.drawer-footer .drawer-confirm-btn {
  width: 100%;
  padding: 0.85rem;
  background: #537D5D;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.drawer-footer .drawer-confirm-btn:hover {
  background: #446650;
}

/* Override compact table for drawer specific look */
.drawer-body .compact-table th {
  background: #f1f3f1;
  color: #537D5D;
  border-bottom: 2px solid #D2D0A0;
  font-weight: 700;
}

.drawer-body .compact-table td {
  padding: 1rem 0.5rem;
  border-bottom: 1px solid #f0f0f0;
}

/* 關閉時：面板往右滑回去收起，遮罩同步淡出 */
.drawer-panel.is-closing {
  animation: slideOutRight 0.3s ease forwards;
}

.drawer-overlay.is-closing {
  animation: drawerOverlayFadeOut 0.3s ease forwards;
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(100%);
  }
}

@keyframes drawerOverlayFadeOut {
  from {
    background: rgba(0, 0, 0, 0.4);
  }

  to {
    background: rgba(0, 0, 0, 0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

/* 輔助樣式：.compact-table 已併到「Like Query Styles」那一條（2026-10-22） */

/* 權限指派專用樣式 */
.assign-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.perm-group-box {
  background: #fdfdfd;
  /* Slightly off-white for card effect */
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  /* Lift it up */
}

.group-title {
  background: #f4f4f4;
  padding: 0.8rem 1.2rem;
  font-weight: 700;
  color: #333;
  border-bottom: 1px solid #ddd;
  margin-bottom: 0;
}

.group-items {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  background: #fafafa;
  /* Distinct from item colors */
}

/* --- Toggle & Switch Components --- */
.view-toggles {
  display: inline-flex;
  background: white;
  border: 1px solid var(--color-beige);
  padding: 4px;
  border-radius: 50px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.toggle-btn {
  background: transparent;
  border: none !important;
  padding: 0.6rem 1.5rem !important;
  border-radius: 50px !important;
  cursor: pointer;
  font-size: 1rem !important;
  font-weight: 600 !important;
  color: var(--color-med-green) !important;
  transition: all 0.25s ease !important;
  white-space: nowrap;
}

.toggle-btn:hover {
  background: #fcfdf9;
  color: var(--color-dark-green) !important;
}

.toggle-btn.active {
  background: var(--color-dark-green) !important;
  color: white !important;
  box-shadow: 0 4px 10px rgba(83, 125, 93, 0.2);
}

/* --- Global Navigation Dropdowns（舊版，已移除）---
   2026-10-22 刪除 nav-dropdown、dropdown-trigger、dropdown-content 的整組規則 ——
   NavBar.razor 改用 iva-nav-dropdown／iva-dropdown-content 之後就沒有人用了。 */

/* ⚠️ 只有這一條還在生效，不要一起刪：[class*=] 是「名字裡包含這段字」的比對，
   正好套到 NavBar 的 iva-lang-dropdown-container > iva-dropdown-content（語系選單靠右對齊）。 */
[class*="lang-dropdown"]>[class*="dropdown-content"] {
  left: auto !important;
  right: 0 !important;
  transform: none !important;
}

/* ============================================================
   暗色主題 Dark Mode — 僅在 html[data-theme="dark"] 生效
   亮色 :root 與既有樣式完全不受影響（此區為純疊加覆寫）。
   目前範圍：對外公開頁面（首頁/投票、入圍、得獎、歷屆）
   ============================================================ */
html[data-theme="dark"] {
  /* 核心變數覆寫（沿用實驗室調好的色碼） */
  --color-dark-green: #7fb389;
  --color-med-green: #7fb389;
  --color-light-green: #7fb389;
  --color-beige: #3a443d;
  --color-bg: #131815;
  --iva-card-bg: #1e2521;
  --iva-text-dark: #f3e9dc;
  /* 次要文字：原本是 #9aa89c，那是**綠調**灰，用在石板藍（入圍）與紫藍（排名）
     主題上會泛綠。改成真中性灰，三頁共用一支（方案 A）。 */
  --iva-text-muted: #a2a8a6;
  /* 自訂強調 / Hero / 按鈕（供下方規則引用） */
  --color-voted: #b85d2a; /* 2026-10-22 由 #d96f32 調暗：暗底上太亮 */
  --color-gold: #f2d479;
  --color-btn-text: #131815;
  --color-hero-from: #2d4a36;
  --color-hero-to: #4a6b52;
  --color-hero-text: #fdf6ed;
  /* .placeholder-hero::before 那層遮罩用的半透明版本。
     必須另外開 rgba token —— rgba() 沒辦法直接吃上面的 hex token。
     色值刻意對齊 --color-hero-from / --color-hero-to。 */
  --color-hero-overlay-from: rgba(45, 74, 54, 0.92);
  --color-hero-overlay-to: rgba(74, 107, 82, 0.86);
  /* 名次色階：亮色是「淺底深字」，暗色反過來「深底亮字」，色相保持不變。
     銀＝冷調、銅＝暖調，金牌沿用既有的 --color-gold 色值。 */
  --tier-gold-bg: #3a3320;
  --tier-gold-fg: #f2d479;
  --tier-silver-bg: #2d353d;
  --tier-silver-fg: #cbd5e1;
  --tier-bronze-bg: #3a2a1e;
  --tier-bronze-fg: #f0b088;
  --tier-other-bg: #2e3631;
  --tier-other-fg: #a2a8a6;
  --color-filter-text: #131815;
  /* 深底上的陰影需加重 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* --- 原本寫死 white 的卡片 / 容器 --- */
html[data-theme="dark"] .player-section,
html[data-theme="dark"] .active-work-details,
html[data-theme="dark"] .work-card,
html[data-theme="dark"] .work-detail-page .active-player-container {
  background-color: var(--iva-card-bg);
}
html[data-theme="dark"] .active-work-details { border-left-color: var(--color-beige); }
html[data-theme="dark"] .detail-actions { border-top-color: #2a322d; }

/* --- 表單輸入 --- */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background-color: var(--iva-card-bg);
  color: var(--iva-text-dark);
  border-color: var(--color-beige);
}
html[data-theme="dark"] .clear-search-btn { background: #2a322d; color: var(--iva-text-muted); }

/* --- 主文字（原本用深綠當文字色，暗色改用米白以維持易讀） --- */
html[data-theme="dark"] .work-title,
html[data-theme="dark"] .detail-title { color: var(--iva-text-dark); }
html[data-theme="dark"] .detail-author { color: var(--iva-text-muted); }

/* --- 作品卡片：作品編號 / 組長組員 / 分享鍵 ---

   ⚠️ 在此之前投票頁卡片這三處**完全沒有暗色規則**，行內的 #888 / #666 深灰字
      直接留在 #1e2521 卡底上，對比只有約 1.9:1，幾乎讀不到。

   ⚠️ 色值寫在 Home.razor 的**行內 style**，而行內樣式贏過沒有 !important 的規則，
      所以這裡非加 !important 不可 —— 拿掉就會失效。

   層級規則（三頁統一）：標籤＝次要色、姓名＝主要文字色。
   入圍頁與排名頁各自有更高特異性的同名規則，會蓋掉這裡的預設值。 */
html[data-theme="dark"] .work-card .work-code-label,
html[data-theme="dark"] .work-card .work-team,
html[data-theme="dark"] .work-card .work-team strong {
  color: var(--iva-text-muted) !important;
}
html[data-theme="dark"] .work-card .work-team .author-name-unit {
  color: var(--iva-text-dark) !important;
}

/* 卡片標題：亮色是主題色（.work-title 用 var(--color-dark-green)），
   所以暗色也要用主題色，否則切換主題時標題的角色會從「主題色」變成「中性米白」。
   在暗色下 --color-dark-green 已被覆寫為 #7fb389。

   :not(.shortlist-theme) 是必要的 —— 入圍頁同樣掛 .home-container，但它把
   --color-dark-green 覆寫成亮色的 #245269（那支在該頁被當 Hero 背景色用），
   直接套用會得到深藍字。入圍頁的卡片標題由它自己的規則負責。 */
html[data-theme="dark"] .home-container:not(.shortlist-theme) .work-card .work-title {
  color: var(--color-dark-green);
}
/* 分享鍵：行內是亮色主色 #73946B，深底上偏暗，改用暗色版主綠 */
html[data-theme="dark"] .work-card .share-btn {
  color: var(--color-dark-green) !important;
}

/* --- 按讚按鈕 --- */
html[data-theme="dark"] .like-button { color: var(--color-btn-text); }
html[data-theme="dark"] .like-button.voted { background-color: var(--color-voted) !important; }

/* --- 篩選器：未選中按鈕（原本白底太亮，改為深色底 + 細邊框 + 灰綠字） --- */
html[data-theme="dark"] .filter-bar button:not(.active) {
  background: #242b27;
  border-color: #3a443d;
  color: #9aa89c;
}
html[data-theme="dark"] .filter-bar button:not(.active):hover { background: #2e3631; }
/* --- 篩選器選中文字（原 white） --- */
html[data-theme="dark"] .filter-bar button.active { color: var(--color-filter-text); }

/* --- Hero 公告模式（原 #537D5D !important） --- */
html[data-theme="dark"] .player-section.hero-mode {
  background-color: var(--color-hero-from) !important;
  background-image: linear-gradient(135deg, var(--color-hero-from), var(--color-hero-to)) !important;
}
html[data-theme="dark"] .hero-title,
html[data-theme="dark"] .hero-desc,
html[data-theme="dark"] .info-item,
html[data-theme="dark"] .info-label,
html[data-theme="dark"] .info-value { color: var(--color-hero-text) !important; }

/* ⚠️ 這條是暗色模式下公告區真正的顯色來源，**不要以為上面那條就夠了**。
   .placeholder-hero::before（第 789 行附近）用 inset: 0 + z-index: 1 蓋滿整塊，
   而且亮綠 rgba 帶 !important —— 父層 .hero-mode 就算已經換成深綠漸層，
   也會被這層遮罩整片蓋掉。暗色模式一直是亮綠的原因就在這裡（偽元素被漏掉了）。
   保留半透明（不用純色）是為了讓底下的背景照片仍有層次，與亮色模式的設計意圖一致。
   註：.placeholder-hero 是 app.css 全域類別，Shortlist 頁的同款區塊也會一起變深（刻意為之）。 */
html[data-theme="dark"] .placeholder-hero::before {
  background: linear-gradient(135deg, var(--color-hero-overlay-from), var(--color-hero-overlay-to)) !important;
}

/* 深底上 rgba(255,255,255,0.2) 的白框太搶眼，略降透明度 */
html[data-theme="dark"] .hero-content {
  border-color: rgba(255, 255, 255, 0.12);
}

/* 「目前投票規則」的強調色：亮色是墨藍 #1B3A4B（Home.razor.css），
   但上面 .info-value 的 !important 會把它一起壓成米白，強調就消失了。
   深底上改用既有的金色 token，對比比墨藍好得多。 */
html[data-theme="dark"] .rule-highlight .info-value {
  color: var(--color-gold) !important;
}

/* --- 頁尾 --- */
html[data-theme="dark"] .footer { background: rgba(58, 68, 61, 0.2); border-top-color: var(--color-beige); }

/* --- 首頁手機版排序下拉（Home.razor.css 內為白底） --- */
html[data-theme="dark"] .home-dropdown-trigger { background: var(--iva-card-bg); color: var(--color-med-green); }
html[data-theme="dark"] .home-dropdown-menu-container { background: var(--iva-card-bg); }
html[data-theme="dark"] .home-dropdown-item { color: var(--iva-text-dark); border-bottom-color: #2a322d; }
html[data-theme="dark"] .home-dropdown-item:hover { background: #2a322d; color: var(--color-med-green); }

/* --- 投票頁：支持進度 --- */
html[data-theme="dark"] .voting-progress-wrapper:not(.is-completed) .progress-label {
  color: var(--iva-text-muted);
}
html[data-theme="dark"] .voting-progress-wrapper:not(.is-completed) .progress-count {
  color: var(--color-med-green);
}
html[data-theme="dark"] .voting-progress-wrapper .progress-track {
  background: #2a322d;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

@media (max-width: 768px) {
  /* 手機版進度列為 sticky 面板，需覆寫 Home.razor.css 的白色半透明背景。 */
  html[data-theme="dark"] .voting-progress-wrapper {
    background: rgba(30, 37, 33, 0.95);
    border-bottom-color: #3a443d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  }
}

/* ============================================================
   後台暗色基底層 (Phase 1)
   涵蓋：A 類 app.css 自訂後台類別 ＋ B 類 Bootstrap 5.1 元件
   全部僅在 html[data-theme="dark"] 生效，亮色不受影響。
   深色面板色階：頁底 #131815 / 卡片 #1e2521 / 次層 #242b27 / hover #2e3631 / 邊框 #3a443d
   ============================================================ */

/* ---------- B 類：Bootstrap 5.1 元件 ---------- */
/* 卡片 */
html[data-theme="dark"] .card {
  background-color: var(--iva-card-bg);
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer {
  background-color: #242b27;
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}

/* 表格 */
html[data-theme="dark"] .table {
  color: var(--iva-text-dark);
  border-color: var(--color-beige);
  --bs-table-bg: var(--iva-card-bg);
  --bs-table-color: var(--iva-text-dark);
  --bs-table-striped-bg: #232a26;
  --bs-table-striped-color: var(--iva-text-dark);
  --bs-table-hover-bg: #2e3631;
  --bs-table-hover-color: var(--iva-text-dark);
}
html[data-theme="dark"] .table > :not(caption) > * > * { border-bottom-color: var(--color-beige); }
html[data-theme="dark"] .table-light,
html[data-theme="dark"] .table-light > th,
html[data-theme="dark"] .table-light > td {
  --bs-table-bg: #242b27;
  color: var(--iva-text-dark);
  border-color: var(--color-beige);
}
html[data-theme="dark"] .table thead th { color: var(--iva-text-muted); }

/* 清單群組 */
html[data-theme="dark"] .list-group-item {
  background-color: var(--iva-card-bg);
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .list-group-item-action:hover,
html[data-theme="dark"] .list-group-item-action:focus {
  background-color: #2e3631;
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .list-group-item.active {
  background-color: var(--color-dark-green);
  border-color: var(--color-dark-green);
  color: #131815;
}

/* 彈窗 / 下拉 */
html[data-theme="dark"] .modal-content {
  background-color: var(--iva-card-bg);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer { border-color: var(--color-beige); }
html[data-theme="dark"] .dropdown-menu {
  background-color: var(--iva-card-bg);
  border-color: var(--color-beige);
}
html[data-theme="dark"] .dropdown-item { color: var(--iva-text-dark); }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus { background-color: #2e3631; color: var(--iva-text-dark); }
html[data-theme="dark"] .dropdown-divider { border-top-color: var(--color-beige); }
/* 關閉鈕 (深色化原本的黑色 X) */
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.8); }

/* 表單 */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background-color: var(--iva-card-bg);
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .form-control::placeholder { color: #6b7670; }
html[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239aa89c' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
html[data-theme="dark"] .input-group-text {
  background-color: #242b27;
  border-color: var(--color-beige);
  color: var(--iva-text-muted);
}
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .col-form-label { color: var(--iva-text-dark); }

/* 按鈕（僅中性色系；彩色語意按鈕維持原樣） */
html[data-theme="dark"] .btn-light {
  background-color: #242b27;
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-dark { color: #c9cfc7; border-color: var(--color-beige); }
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-dark:hover { background-color: #2e3631; color: #fff; border-color: var(--color-beige); }

/* 分頁籤 / 分頁器 */
html[data-theme="dark"] .nav-tabs { border-bottom-color: var(--color-beige); }
html[data-theme="dark"] .nav-tabs .nav-link { color: var(--iva-text-muted); }
html[data-theme="dark"] .nav-tabs .nav-link.active {
  background-color: var(--iva-card-bg);
  border-color: var(--color-beige) var(--color-beige) var(--iva-card-bg);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .page-link {
  background-color: var(--iva-card-bg);
  border-color: var(--color-beige);
  color: var(--color-med-green);
}

/* 提示框（中性色系；success/danger/warning 維持原色） */
html[data-theme="dark"] .alert-secondary,
html[data-theme="dark"] .alert-light {
  background-color: #242b27;
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .alert-info {
  background-color: #1e2b2e;
  border-color: #2f4a52;
  color: #bfe3ec;
}
/* 彩色語意提示：暗色下改「深底 + 語意色文字」，避免在深色頁上變成刺眼淺色塊 */
html[data-theme="dark"] .alert-success {
  background-color: #16281c;
  border-color: #2f5a3a;
  color: #a6d8b0;
}
html[data-theme="dark"] .alert-warning {
  background-color: #332b12;
  border-color: #5a4f2a;
  color: #f2d479;
}
html[data-theme="dark"] .alert-danger {
  background-color: #331f1f;
  border-color: #5a2f2f;
  color: #f5a9a9;
}

/* Bootstrap 工具類（皆為 !important，覆寫亦需 !important） */
html[data-theme="dark"] .bg-light { background-color: #242b27 !important; }
html[data-theme="dark"] .bg-white { background-color: var(--iva-card-bg) !important; }
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-secondary { color: var(--iva-text-muted) !important; }
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-body { color: var(--iva-text-dark) !important; }
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,
html[data-theme="dark"] .border-end { border-color: var(--color-beige) !important; }

/* ---------- A 類：app.css 自訂後台類別 ---------- */
/* 分頁標籤 */
html[data-theme="dark"] .admin-tabs,
html[data-theme="dark"] .perm-side-nav { border-bottom-color: var(--color-beige); }
html[data-theme="dark"] .bookmark-tab { color: var(--iva-text-muted); }
html[data-theme="dark"] .bookmark-tab:hover { background: #2e3631; }
html[data-theme="dark"] .bookmark-tab.is-active { background: var(--iva-card-bg); color: var(--iva-text-dark); border-color: var(--color-beige); border-bottom-color: var(--iva-card-bg); }

/* 卡片 / 面板容器 */
html[data-theme="dark"] .stat-box,
html[data-theme="dark"] .like-query-card,
html[data-theme="dark"] .detail-card,
html[data-theme="dark"] .preview-panel,
html[data-theme="dark"] .maintenance-card,
html[data-theme="dark"] .upload-card,
html[data-theme="dark"] .preview-card,
html[data-theme="dark"] .review-table-section,
html[data-theme="dark"] .perm-main-panel,
html[data-theme="dark"] .perm-group-box,
html[data-theme="dark"] .user-detail-side {
  background: var(--iva-card-bg);
  border-color: var(--color-beige);
  color: var(--iva-text-dark);
}
html[data-theme="dark"] .user-list-side,
html[data-theme="dark"] .table-container,
html[data-theme="dark"] .works-list-compact { border-color: var(--color-beige); }

/* 資料表（自訂） */
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .review-table th,
html[data-theme="dark"] .members-table th,
html[data-theme="dark"] .compact-table th { background: #242b27; color: var(--iva-text-muted); }
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .review-table th,
html[data-theme="dark"] .review-table td,
html[data-theme="dark"] .members-table th,
html[data-theme="dark"] .members-table td,
html[data-theme="dark"] .compact-table th,
html[data-theme="dark"] .compact-table td { border-bottom-color: var(--color-beige); }
html[data-theme="dark"] .review-table tr:hover { background-color: #2e3631; }
html[data-theme="dark"] .review-table tr.selected-row,
html[data-theme="dark"] .compact-table tr.selected { background-color: #2e3631; }

/* 按讚明細 / 抽屜 / 群組 */
html[data-theme="dark"] .like-details-panel { background: #1e2521 !important; border-color: var(--color-beige) !important; }
html[data-theme="dark"] .records-list { background: var(--iva-card-bg); border-color: var(--color-beige); }
html[data-theme="dark"] .details-header,
html[data-theme="dark"] .drawer-header,
html[data-theme="dark"] .drawer-footer,
html[data-theme="dark"] .group-title { background: #242b27; border-bottom-color: var(--color-beige); color: var(--iva-text-dark); }
html[data-theme="dark"] .drawer-panel,
html[data-theme="dark"] .group-items { background: var(--iva-card-bg); }
html[data-theme="dark"] .drawer-footer { border-top-color: var(--color-beige); }

/* 檔案 / 上傳 / 切換 */
html[data-theme="dark"] .drop-zone { background: #1e2521; }
html[data-theme="dark"] .view-toggles { background: var(--iva-card-bg); border-color: var(--color-beige); }

/* 統計數字與雜項文字 */
html[data-theme="dark"] .big-number,
html[data-theme="dark"] .panel-title,
html[data-theme="dark"] .card-title { color: var(--color-med-green); }
html[data-theme="dark"] .update-time { color: var(--iva-text-muted); }

/* ============================================================
   頂層模式切換條（.iva-mode-*）
   ------------------------------------------------------------
   「這一頁有兩種身分」的那條膠囊按鈕列。抽獎頁、翻譯管理頁、
   語系檔案管理頁各自在自己的 scoped CSS 裡抄了一份 `.mode-selector`
   ／`.mode-btn`（連暗色覆寫都各一份），改一次外觀要改三處 ——
   ISSUES.md 第 5、23 項講的就是這種重複。

   ⚠️ 名字**刻意不叫** .mode-btn：Admin.razor.css 已經有一個同名的
      小型文字切換鈕（「查詢作品／查詢投票者」），沿用會互相打架。
      那一頁的 .mode-btn 是**不同的東西，不要動它**。

   2026-09-10：那三頁也換過來了，五個使用端（抽獎、翻譯管理、語系檔案管理、
   Admin 的模式列、ShortlistManager）現在共用這一份，重複已收斂完畢。
   ⚠️ 收斂時發現三份**其實已經分歧**：抽獎頁與語系檔案管理頁的暗色 active 是
      深綠底(#537D5D)+米白字，翻譯管理頁是淺綠底(#7fb389)+深字。統一採用後者
      （與 Admin／ShortlistManager 相同），所以前兩頁的暗色 active 外觀有變。
   ============================================================ */
.iva-mode-selector {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.iva-mode-btn {
  padding: 12px 35px;
  border-radius: 30px;
  border: 2px solid #537D5D;
  background: white;
  color: #537D5D;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.05rem;
}

.iva-mode-btn.active {
  background: #537D5D;
  color: white;
  box-shadow: 0 5px 15px rgba(83, 125, 93, 0.3);
}

.iva-mode-btn:hover:not(.active) {
  background: #f0f7f2;
}

html[data-theme="dark"] .iva-mode-btn {
  background: #1e2521;
  color: #7fb389;
  border-color: #7fb389;
}
html[data-theme="dark"] .iva-mode-btn:hover:not(.active) {
  background: #2e3631;
}
html[data-theme="dark"] .iva-mode-btn.active {
  background: #7fb389;
  color: #1e2521;
}

/* ============================================================
   自訂下拉選單（.home-dropdown-*）
   2026-10-08：原本寫在 Home.razor.css，是 scoped CSS，只有首頁吃得到。
   後台「人氣排行總榜」要用同一套外觀，於是整組搬到這裡成為全站共用。
   選擇器一字未改，首頁與歷屆頁的外觀不受影響。
   深色模式覆寫本來就在本檔（搜尋 html[data-theme="dark"] .home-dropdown-trigger），
   它的選擇器權重較高，放在本區塊之前也仍然蓋得過。

   ⚠️ 原檔寫的是 @@keyframes（.css 檔裡 @@ 不是逸出，是字面值），
      所以展開動畫其實一直沒有生效。搬過來時一併改成合法的 @keyframes。
   ============================================================ */
.home-custom-dropdown {
  position: relative;
  width: 100%;
  z-index: 1000;
}

.home-dropdown-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-radius: 12px;
  border: 2px solid #537D5D;
  background: white;
  color: #537D5D;
  font-weight: 700;
  font-size: clamp(0.95rem, 4.5vw, 1.15rem);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(83, 125, 93, 0.08);
  transition: all 0.3s;
}

.home-dropdown-trigger:hover {
  box-shadow: 0 6px 20px rgba(83, 125, 93, 0.15);
}

.home-custom-dropdown.open .home-dropdown-trigger {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.home-dropdown-arrow {
  width: 10px;
  height: 10px;
  border-right: 2px solid #537D5D;
  border-bottom: 2px solid #537D5D;
  transform: rotate(45deg);
  transition: 0.3s;
  margin-left: 15px;
  margin-bottom: 4px;
}

.home-custom-dropdown.open .home-dropdown-arrow {
  transform: rotate(-135deg);
  margin-bottom: -4px;
}

.home-dropdown-menu-container {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  border: 2px solid #537D5D;
  border-top: none;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 1001;
  animation: home-slideIn 0.2s ease-out;
}

@keyframes home-slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-dropdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.home-dropdown-item {
  padding: 15px 20px;
  cursor: pointer;
  transition: 0.2s;
  font-weight: 600;
  color: #4a5568;
  font-size: 1rem;
  border-bottom: 1px solid #f0f0f0;
}

.home-dropdown-item:last-child {
  border-bottom: none;
}

.home-dropdown-item:hover {
  background: #f0fdf4;
  color: #537D5D;
}

.home-dropdown-item.active {
  background: #537D5D;
  color: white;
}

.home-dropdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  background: rgba(0, 0, 0, 0.05);
}

/* 後台的下拉不需要首頁那種手機版大字，稍微收斂一點。 */
.admin-sort-dropdown .home-dropdown-trigger {
  padding: 10px 16px;
  font-size: 0.95rem;
}

.admin-sort-dropdown .home-dropdown-item {
  padding: 11px 16px;
  font-size: 0.95rem;
}
