/* ==========================================================================
   樣式
   --------------------------------------------------------------------------
   卡片規格（使用者 2026-10-21 v1.3）
     縮圖 560×420、object-fit: contain（**不裁切、不變形**）
     中欄 7 行、右欄 7 行
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #14161a;
  --bg2: #1b1e24;
  --bg3: #23262d;
  --line: #2a2e36;
  --fg: #e6e8eb;
  --muted: #8b929c;
  --accent: #7fb0ff;
  /* ❗ 2026-10-24 修 Lighthouse color-contrast（原本 3.96 / 2.77 / 3.47，門檻 4.5） */
  --good: #5b9cff;      /* on --bg 6.59、on --bg2 6.08 */
  --hot: #ff7b7b;       /* on --bg 7.22、on --bg2 6.66 */
  --hidden: #f0b040;    /* on --bg 9.48、on --bg2 8.74 */
  /* ❗ 白字按鈕的底色要**夠深**：--good(#5b9cff) 白字只有 2.75、
     --accent(#7fb0ff) 只有 2.20（PSI 對首頁報的「はい、18歳以上です」就是這個）。
     #1f5fbf 的白字對比 6.09 ⇒ 過 4.5。 */
  --btn-primary: #1f5fbf;
  --ok: #6ee7a8;
  --warn: #ffb454;
  --thumb-w: 560px;
  --thumb-h: 420px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP",
               "Noto Sans TC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ------------------------------ 頁首 ------------------------------ */
.hdr {
  position: sticky; top: 0; z-index: 50;
  background: rgba(20, 22, 26, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.hdr-in { display: flex; align-items: center; gap: 18px; height: 56px; }
/* ❗ 2026-10-26：日夜切換鈕與語言下拉**往畫面右邊靠**，不要貼著網站標題。
   桌面時 `.nav { flex: 1 }` 已經把控件推到右端（auto margin 吃掉 0 空間，無影響）；
   手機（≤620px）時 nav 換到第二行 ⇒ 這行 auto margin 才是讓控件靠右的關鍵。 */
.hdr-in .theme-toggle { margin-left: auto; }

/* ❗ sticky 頁首的副作用：跳至主要內容（skip-link）與任何 #錨點捲過去時，
   目標會被 56px 的頁首**蓋住上半部**。用 `scroll-margin-top` 預留空間。
   值 = 頁首高度 56 + 8 的呼吸空間。 */
#main, main, [id]:target { scroll-margin-top: 64px; }
.brand { font-weight: 700; font-size: 16px; color: var(--fg); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted);
  white-space: nowrap; font-size: 13px;
}
/* ❗ 2026-10-28：nav 同時有全名（.nav-f）與短名（.nav-s），手機只顯示短名
   —— 英文的 Well-rated / Hidden gems / Hall of Fame 在手機標頭會把 About 擠出畫面。 */
.nav-s { display: none; }
.nav-a:hover { background: var(--bg3); color: var(--fg); text-decoration: none; }
.nav-a.on { background: var(--bg3); color: var(--fg); font-weight: 600; }

.lang { display: flex; align-items: center; flex: 0 0 auto; }
.lang-a {
  padding: 4px 8px; border-radius: 5px; font-size: 12px; color: var(--muted);
}
.lang-a.on { background: var(--bg3); color: var(--fg); }

/* ------------------------------ 頁尾 ------------------------------ */
.ftr { border-top: 1px solid var(--line); margin-top: 40px; padding: 20px 0; font-size: 12px; }
.ftr p { margin: 4px 0; color: var(--muted); }
/* ❗ 2026-10-25：頁尾的「隱私權政策 / 問題回報」連結列
   —— 隱私政策只放導覽列不好找，頁尾是慣例位置。 */
.ftr-links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.ftr-links a { color: var(--muted); text-decoration: none; }
.ftr-links a:hover { color: var(--accent); text-decoration: underline; }

/* ---------------------------------------------------------------------------
   隱私權政策頁的資料表（Cookie 一覽、收集項目）
   窄螢幕時橫向捲動，不要讓表格撐破版面。
   --------------------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; margin: 12px 0 18px; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.7; }
.tbl th, .tbl td {
  padding: 8px 10px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.tbl th { color: var(--fg2); font-weight: 600; white-space: nowrap; }
.tbl td { color: var(--muted); }
.tbl tbody tr:last-child th, .tbl tbody tr:last-child td { border-bottom: none; }
.tbl code {
  background: var(--bg3); border-radius: 4px; padding: 1px 5px;
  color: var(--fg); font-size: 12px;
}

/* ------------------------------ 頁面標題區 ------------------------------ */
/* 跳至主要內容：平常移出畫面，Tab 聚焦時才出現 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 2000;
  padding: 10px 18px;
  border-radius: 0 0 8px 0;
  background: var(--btn-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { left: 0; outline: 2px solid #fff; outline-offset: -4px; }

.page-head { padding: 22px 0 12px; }
.page-head h1 { margin: 0 0 6px; font-size: 22px; }
.page-head .desc { color: var(--muted); font-size: 13px; }
.page-head .meta { margin-top: 8px; font-size: 12px; color: var(--muted); }
.page-head .meta b { color: var(--accent); font-weight: 600; }
.total { float: right; font-size: 13px; color: var(--muted); }

/* ------------------------------ 篩選 ------------------------------ */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.filters label { font-size: 12px; color: var(--muted); }
/* ❗ 2026-10-25：關鍵字獨立成一行（放最上面，較顯眼）
   —— `flex: 1 0 100%` 讓它在 flex 版佔滿一整列；
      格線版（≤900px）用 `grid-column: 1 / -1`。 */
.filters-kw {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
}
.filters-kw input[type=text] {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  padding: 8px 12px;
}
.filters-kw-clear {
  flex: 0 0 auto;
  padding: 0 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.filters-kw-clear:hover { color: var(--accent); }
/* ❗ 2026-10-26（使用者回饋，手機截圖）：
   原本 label 與 select 是 `.filters` 的**兩個獨立子元素**。
   桌面的 flex row 沒問題，但 ≤620px 改成 grid 後，
   每個篩選會固定佔「label 一列 + select 一列」= 2 列，
   6 個篩選就是 12 列 ⇒ 一進排行頁整畫面都是篩選。

   把每組包進 `.ff`，讓它成為**單一 grid item**：
     桌面／平板 → `.ff` 內部是 flex row（label 左、select 右），外觀不變
     ≤620px   → `.ff` 內部改成直向（label 小字在上、select 在下），格子 2 欄
   ⇒ 6 個篩選從 12 列變成 **3 列**。 */
.ff { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ff select { min-width: 0; }
.filters input[type=text] { min-width: 170px; }
.filters select, .filters input[type=text] {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; font-size: 13px;
}
.filters .btn {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  /* ❗ 2026-10-25：全域 `.btn` 的 `min-height:44px` 與 `margin-top:18px`
     會讓這顆按鈕比同一排的 `<select>`（約 30px）高出 14px。
     這裡把它抵銷掉，讓 padding + font-size 自然決定高度，
     就會和 select 一致（兩者的 padding / font-size / 邊框都相同）。 */
  min-height: 0;
  margin-top: 0;
}
.filters .btn:hover { border-color: var(--accent); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
.chip a { color: var(--muted); }
.chip a:hover { color: #ff9b9b; }

/* ------------------------------ 卡片 ------------------------------ */
.card {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 14px 56px;
  margin-bottom: 14px;
}
.card:hover { border-color: #3a4050; }

.rank-no {
  position: absolute; left: 14px; top: 16px;
  width: 30px; text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 17px; color: var(--accent);
  /* ❗ 2026-10-28：手機版縮圖改成 `width:100%` 且 `.thumb-link` 是 position:relative，
     會把排名編號蓋掉（使用者回報「手機看不到排名編號」）。
     兩者都是 positioned ⇒ 由 DOM 順序決勝：`rank-no` 在前、縮圖在後 ⇒ 縮圖在上。
     ⇒ 給排名編號 z-index，讓它永遠浮在上面。 */
  z-index: 3;
}

.card-main { display: flex; gap: 16px; align-items: flex-start; }

/* 縮圖：固定 560×420、等比縮放不裁切 */
.card-thumb-wrap { flex: 0 0 var(--thumb-w); width: var(--thumb-w); }
.thumb-link { position: relative; display: block; width: var(--thumb-w); height: var(--thumb-h); }
.card-thumb {
  width: var(--thumb-w); height: var(--thumb-h);
  object-fit: contain;          /* ← 不是 cover：保持原圖比例 */
  background: #101215;
  border-radius: 8px;
  display: block;
}
.card-thumb.noimg { background: var(--bg3); }
/* 字色由 PHP 依背景亮度inline 指定（見 site_badge_text_color） */
/* ❗ 2026-10-29（使用者）：R15 小標籤要「緊靠分站小標籤的右邊」。
   分站名稱長度不固定 ⇒ 用一層 flex 容器定位，兩個標籤自然併排。
   容器接手原本 `.site-badge` 的絕對定位座標。 */
.thumb-badges {
  position: absolute; top: 8px; left: 8px;
  display: flex; align-items: center;
  /* ❗ 2026-10-29（使用者）：手機版「名次↔站台」與「站台↔R15」的間隔要一樣大。
     名次↔站台是 8px（由 `data-rank-len` 的 left 偏移 44/52/60/68 決定，
     = 名次右緣 + 8px）⇒ 這裡也必須是 8px。
     原本 4px，實測截圖是 9px vs 5px，明顯不一致。 */
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}
/* ❗❗ 2026-10-30（使用者第三輪）：PC 的兩個膠囊要**完全齊平、跟手機一致**。
   原本站台膠囊靠 `padding:3px 9px` + `line-height:normal` 撐高度 ——
   CJK 字型的 normal 約 1.45 ⇒ 實際約 **23.4px**，而 R15 膠囊我寫死 `line-height:1.15`
   ⇒ 只有 22.1px ⇒ **結果 age 反而比較小**（使用者回報「PC 上 age 膠囊比較小」）。
   ⇒ 兩者都改成**明確的 height:22px + line-height:1 + inline-flex 置中**
      （與手機版完全相同的幾何），高度不再受字型行高影響。
      字級維持：站台 12px／R15 14px（R15 仍比站台大一級）。 */
.site-badge {
  text-shadow: none;
  height: 22px; display: inline-flex; align-items: center;
  padding: 0 9px; border-radius: 5px; line-height: 1;
  font-size: 12px; font-weight: 700; color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
/* R15：淡綠底 + 深綠字（`home` 站台標籤是亮綠 #68d917 深字，兩者不會混淆） */
.age-badge {
  height: 22px; display: inline-flex; align-items: center;
  padding: 0 10px; border-radius: 5px; line-height: 1;
  font-size: 14px; font-weight: 800;
  letter-spacing: .3px;
  background: #bff5c6; color: #0d3d17;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}

/* 中欄 7 行 */
.card-mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-mid .m1 { font-size: 15px; line-height: 1.4; font-weight: 600; }
.card-mid .m1 a { color: var(--fg); }
.card-mid .m1 a:hover { color: var(--accent); }
.card-mid .m2 { font-size: 13px; color: var(--muted); }
.card-mid .m3 { font-size: 13px; color: var(--muted); }
.card-mid .m4 { font-size: 14px; }
.card-mid .m5, .card-mid .m6 { font-size: 13px; color: var(--muted); }
/* ❗ 聲優（.m5）與插畫/作者/劇本/音樂（.m6）要用同一套外觀 —— 使用者 2026-10-24 */
.card-mid .m5 .k,
.card-mid .m6 .k,
.card-mid .m8 .k {
  display: inline-block; background: var(--bg3); border-radius: 4px;
  padding: 0 6px; margin-right: 6px; font-size: 11px; color: var(--fg);
}
.card-mid .m6 { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.card-mid .m6 .grp { display: inline-flex; align-items: baseline; gap: 2px; }
.card-mid .m7 { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  display: inline-block; background: var(--bg3); border-radius: 999px;
  padding: 2px 9px; font-size: 12px; color: var(--accent);
}
.tag:hover { background: #2c3446; text-decoration: none; }

.price { font-variant-numeric: tabular-nums; }
.price del { color: var(--muted); margin-right: 4px; }
.price strong { color: #ff8a80; }
.price .disc { color: var(--warn); font-size: 12px; }
.price-free { color: var(--ok); font-weight: 700; }

.nolink-note { font-size: 11px; color: var(--warn); }

/* 右欄 7 行 */
.card-right {
  flex: 0 0 168px; width: 168px;
  text-align: right; display: flex; flex-direction: column; gap: 4px;
}
.card-right .score {
  font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 700; color: var(--ok); line-height: 1.2;
}
.card-right .line { font-size: 12px; }
.card-right .line small { color: var(--muted); }
.stars { color: #ffc247; letter-spacing: 1px; }
.stars-empty { color: #4a4f59; }

.badges { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; margin-top: 4px; }
.badge {
  display: inline-block;
  background: var(--bg3); border-radius: 4px; padding: 1px 7px;
  font-size: 11px; color: var(--muted);
}
.badge small { color: var(--muted); }  /* ❗ 不用寫死色，否則深色主題對比不足 */
.badge-top { background: #3d2f12; color: #ffc247; }

/* 試聽 */
.card-embeds { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.embed-stage {
  position: relative;
  /* ❗ CLS：還沒載入時就要把高度佔好。
     原本 facade 160px、iframe 215px → 點擊後版面上跳 55px（CLS 扣分）。
     改成 stage 固定高度、facade 與 iframe 都吃 100% ⇒ 載入前後同樣高，位移 0。 */
  height: 215px;
}

/* 試聽 facade：使用者點擊前不建立 iframe（省下整首音檔的下載）
   見 card.php 檔頭與 app.js initEmbeds 的說明。 */
.embed-facade {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;          /* 跟著 .embed-stage，避免載入 iframe 時位移 */
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101215;
  cursor: pointer;
  overflow: hidden;
}
.embed-facade img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .45;
}
.embed-facade-ico {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding-left: 4px;            /* 讓 ▶ 視覺置中 */
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}
.embed-facade-tx {
  position: relative;
  z-index: 1;
  margin-left: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .85);
}
.embed-facade:hover .embed-facade-ico,
.embed-facade:focus-visible .embed-facade-ico {
  border-color: #fff;
  background: #0b5ed7;
}
.embed-facade:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* facade 是 <a>（不是 button）：拿掉連結的底線與顏色，看起來仍像按鈕 */
a.embed-facade,
a.embed-facade:hover,
a.embed-facade:focus {
  color: #fff;
  text-decoration: none;
}

/* ❗ 2026-10-24 使用者回報：「手機版的 chobit embed 太寬了，
   player 只能按到 ⏮ 後面的暫停/再生/調音量全部按不到」。
   原因：iframe 寫死 width="740"（桌機版型），手機只有 360~430px → 右側控制項被裁掉。

   chobit 的播放器**本身是響應式的**（有 viewport meta，且 player.css 有
   `@media screen and (max-width: 690px)` 會切成 `.sp` 手機版型），
   所以只要把 iframe 的寬度改成跟著容器，它就會自己重排。
   高度要跟著版型換：
     · 桌機 `.embed`          → 215px（原本就是這個）
     · 手機 `.embed.sp`       → player.css 寫 `min-height: 172px`，給 180 留一點餘裕 */
.embed-stage iframe,
.card-embeds iframe {
  border: 0;
  border-radius: 8px;
  display: none;
  width: 100%;
  max-width: 100%;
  height: 100%;          /* 跟著 .embed-stage（215px / ≤700px 時 220px） */
}
.embed-stage iframe.on { display: block; }
.embed-nav {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  font-size: 12px; color: var(--muted);
}
.embed-nav button {
  background: var(--bg3); border: 1px solid var(--line); color: var(--fg);
  width: 28px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 15px;
  line-height: 1;
}
.embed-nav button:hover { border-color: var(--accent); }
.embed-count { font-variant-numeric: tabular-nums; }

/* ------------------------------ 空狀態 ------------------------------ */
.empty {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 40px 20px; text-align: center;
}
.empty h3 { margin: 0 0 8px; font-size: 16px; }
.empty p { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.empty .btn {
  display: inline-block; background: var(--bg3); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 16px; color: var(--fg);
}

/* ------------------------------ 滾動載入 ------------------------------ */
.sentinel { height: 60px; display: flex; align-items: center; justify-content: center;
            color: var(--muted); font-size: 13px; }

/* ------------------------------ 首頁 ------------------------------ */
.section { margin-bottom: 34px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head .more { margin-left: auto; font-size: 13px; }
/* ❗ 使用者 2026-10-25：首頁的「榜單日期」要與 /rank、/tags 頁一致。
   那兩頁用 `.page-head .meta b { color: var(--accent); font-weight: 600 }`，
   這裡給首頁的 `.section-head .gen b` 同樣的處理。 */
.section-head .gen { font-size: 11px; color: var(--muted); }
.section-head .gen b { color: var(--accent); font-weight: 600; }
.mini-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.mini {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; display: flex; gap: 10px; align-items: flex-start;
}
/* ❗ DLsite 的 image_thum_mini 是 **65×65 正方形**（.webp 僅 1.1 KB），
   所以這裡用 64×64 + object-fit:cover（原本 4:3 主圖才需要 contain）。 */
.mini img { width: 64px; height: 64px; object-fit: cover; background: #101215;
            border-radius: 6px; flex: 0 0 64px; }
.mini .bd { flex: 1; min-width: 0; }
.mini .t {
  font-size: 12px; line-height: 1.35; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.mini .s { font-size: 12px; color: var(--ok); font-weight: 700; margin-top: 4px; }
.mini .r { font-size: 11px; color: var(--muted); }

/* ❗ 2026-11-11（使用者定案）：mini 卡統一
   ① 縮圖＋文字 → DLsite 聯盟連結（整個 .mini-link 可點）
   ② 右下角「詳情」→ 站內作品頁
   ③ 社團名稱單行省略、標題固定兩行 ⇒ 卡片高度一致 */
.mini { position: relative; min-height: 86px; }
.mini .mini-link {
  display: flex; gap: 10px; align-items: flex-start;
  /* ❗ 2026-11-11 修正：不能 color:inherit，否則標題會變成一般文字色（黑／白）。
     保留 <a> 的連結色（深藍／亮藍）才與改版前一致。 */
  flex: 1; min-width: 0; text-decoration: none;
}
.mini .bd { display: flex; flex-direction: column; }
.mini .t { min-height: 2.7em; }
.mini .s {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 3.6em; max-width: 100%;
}
.mini .mini-more {
  position: absolute; right: 10px; bottom: 8px;
  font-size: 11px; font-weight: 700; color: var(--accent);
  text-decoration: none; white-space: nowrap;
}
.mini .mini-more:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .mini .mini-more { font-size: 10px; right: 8px; bottom: 6px; }
}

/* 標籤熱度 */
.tag-rank { list-style: none; margin: 0; padding: 0; }
.tag-row {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 8px; position: relative; overflow: hidden;
}
.tag-row .bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, rgba(47,111,235,.30), rgba(47,111,235,.04));
  pointer-events: none;
}
.tag-row .in { position: relative; display: flex; align-items: baseline; gap: 12px; }
.tag-row .no { width: 32px; text-align: right; color: var(--accent); font-weight: 700;
               font-variant-numeric: tabular-nums; }
.tag-row .nm { font-size: 14px; font-weight: 600; }
.tag-row .sales { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ok); font-weight: 700; }
.tag-row .sub { font-size: 12px; color: var(--muted); margin-top: 4px; position: relative; }

/* ------------------------------ 年齡閘門 ------------------------------ */
/* ❗ 2026-10-24：不要對整個 body 的每個子元素做 `filter: blur(6px)` ——
   那是對整頁做 GPU 模糊，在手機上是很貴的 paint（移動版 Speed Index 3.9s 的疑犯之一），
   而且被模糊的文字在無障礙檢查裡仍然「可見」，Lighthouse 照樣算對比度 → 一定失敗。
   ⇒ 只留遮罩（.age-gate 有自己的半透明底），內容不可點、不可選取即可。 */
body.gated > *:not(.age-gate) { pointer-events: none; user-select: none; }
.age-gate {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 11, 13, .94);   /* 拿掉 blur 後加深，維持「看不清楚」的效果 */
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.age-box {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px 26px; max-width: 460px; width: 100%; text-align: center;
}
.age-box h2 { margin: 0 0 10px; font-size: 19px; }
.age-box p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.age-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.age-actions button {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 20px;
  font-size: 14px; cursor: pointer; background: var(--bg3); color: var(--fg);
}
.age-actions .age-yes { background: var(--btn-primary); border-color: var(--btn-primary); color: #fff; font-weight: 700; }
.age-actions .age-no { background: transparent; color: var(--muted); }
.age-note { margin-top: 16px; font-size: 11px; }

/* ------------------------------ 響應式 ------------------------------ */
@media (max-width: 1180px) {
  :root { --thumb-w: 420px; --thumb-h: 315px; }
  .card-right { flex-basis: 140px; width: 140px; }
}
@media (max-width: 900px) {
  :root { --thumb-w: 300px; --thumb-h: 225px; }
  .card { padding-left: 48px; }
  .card-main { flex-wrap: wrap; }
  .card-mid { flex-basis: calc(100% - var(--thumb-w) - 16px); }
  .card-right {
    flex-basis: 100%; width: 100%; flex-direction: row; flex-wrap: wrap;
    gap: 10px; justify-content: flex-start; text-align: left; margin-top: 8px;
  }
  .badges { flex-direction: row; }
}
@media (max-width: 620px) {
  :root { --thumb-w: 100%; --thumb-h: auto; }
  .card { padding-left: 16px; padding-top: 44px; }
  .rank-no { top: 12px; left: 16px; text-align: left; }
  .card-main { flex-direction: column; }
  .card-thumb { height: auto; aspect-ratio: 4 / 3; }
  .thumb-link { height: auto; }
  .card-mid { flex-basis: auto; }
  /* ❗ 2026-10-29（使用者選方案 A）：首頁每個榜單區改成**單列橫向滑動**。
     原本 2 欄 × 5 列 = 每區 493px、四區 2,252px ⇒ 首頁 3.8 屏。
     改成單列後每區約 159px、四區 636px ⇒ 首頁約 1.3 屏。
     ❗ 卡片全部留在 DOM，只是水平排列 + 可滑動（不影響 SEO）。
     ❗ PC 版完全不受影響（這段在 ≤620px 內）。 */
  .mini-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;               /* Firefox：隱藏捲軸 */
    /* 讓可滑區域延伸到畫面右緣（.wrap 有 16px padding） */
    margin-right: -16px;
    padding-right: 16px;
    padding-bottom: 2px;
  }
  .mini-list::-webkit-scrollbar { display: none; height: 0; }
  .mini {
    flex: 0 0 68%;                        /* 露出下一張約 1/3 ⇒ 暗示可以滑 */
    scroll-snap-align: start;
    min-width: 0;
  }

  /* ❗ 2026-10-29：首頁的標籤熱度 12 列在手機佔 710px ⇒ 只顯示前 5 列。
     用 CSS 隱藏（不動 DOM）：第 6 列以後不顯示，其餘仍可被搜尋引擎讀到。
     ❗ 一定要限定 `.tag-rank--home`：`/tags.php` 也用 `.tag-rank`，
        只寫 `.tag-rank li:nth-child(n+6)` 會把標籤頁也砍成 5 列（已修正）。 */
  .tag-rank--home li:nth-child(n+6) { display: none; }
}

/* ------------------------------ 標籤 autocomplete ------------------------------ */
.filters { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; z-index: 200;
  margin-top: 4px; min-width: 260px; max-height: 320px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
/* ❗ 2026-10-25（AC-8）：符合的字元用「粗體＋主題色」，**不加底色**
   —— 底色（<mark>）在深色主題下容易刺眼，而且站上沒有現成的 mark 樣式。 */
.ac-hl {
  font-weight: 700;
  color: var(--accent);
}
/* 命中語言的別名（AC-2）：`Gal → 辣妹` 的後半，刻意比主名稱淡 */
.ac-alt {
  color: var(--fg2);
  font-weight: 400;
  font-size: 12px;
}
/* 空結果提示（AC-4） */
/* 創作者／社團候選項目的「分類」小標（2026-10-25）
   例：`[聲優] 陽向葵ゅか  3138` —— 讓使用者知道這是哪一種創作者 */
.ac-k {
  flex: 0 0 auto;
  margin-right: 6px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg2);
  font-size: 11px;
  line-height: 18px;
}
.ac-empty {
  padding: 8px 12px;
  color: var(--fg2);
  font-size: 12px;
  line-height: 1.6;
}
.ac-item {
  display: flex; gap: 12px; align-items: baseline;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
}
/* ❗ 2026-10-25：鍵盤反白（↑↓ 移動）—— 與 hover 同樣的視覺，
   但用 class 控制，才能讓「滑鼠移動」與「鍵盤移動」共用同一套樣式。 */
.ac-item.is-active {
  background: var(--bg3);
}
.ac-item:hover { background: var(--bg3); }
.ac-n { flex: 1; }
.ac-w { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mini-noimg { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 6px; background: var(--bg3); }

/* ------------------------------ chips 列（已套用條件 + 標籤輸入）------------------------------ */
/* ❗ 2026-10-28（使用者回報）：小標籤原本全部擠在一起往右堆。
   改成「垂直堆疊」：① 跨類別提示 ② 三個分區（社團／創作者／標籤）③ 輸入列 */
.chips-row {
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
  padding: 0 0 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
/* 跨類別提示：PC 在最左（自己一列的左端）、手機在最上 */
.chips-row .chip-joint { align-self: flex-start; }
/* 三個分區：各自是「虛線框 + 微底色」的小區塊 */
.chip-groups { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.chip-group {
  display: inline-flex; flex-direction: column; gap: 6px;
  padding: 6px 10px 8px;
  border: 1px dashed #3a4050;
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  max-width: 100%;
}
.chip-group-h {
  font-size: 11px; line-height: 1.2; color: var(--muted);
  letter-spacing: .04em;
}
.chip-group-b { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-k { color: var(--muted); font-size: 11px; margin-right: 4px; }
/* ❗ 跨類別的「必定 AND」提示（2026-10-25）
   刻意與 `.chip-op`（可點擊的 AND/OR 切換）區分：
     .chip-op    → 實線邊框 + 強調色 + hover 變化 + cursor:pointer（可切換）
     .chip-joint → 虛線邊框 + 次要色 + 不可點 + cursor:default（固定關係）
   使用者才不會以為「標籤與創作者之間」也能切成 OR。 */
.chip-joint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--fg2);
  font-size: 12px;
  cursor: default;
  user-select: none;
}
.chip-joint > span[aria-hidden] {
  color: var(--accent);
  font-weight: 700;
}
.chip-op {
  color: var(--accent); font-weight: 700; border-color: var(--accent);
}
.tag-input-wrap { position: relative; display: inline-flex; margin-left: auto; }
/* ❗ 2026-10-25：表單內的輸入框不要被 `margin-left:auto` 推到最右邊
   —— 那會讓「創作者」欄位跑到按鈕旁邊、版面斷掉。 */
/* ❗ 2026-11-01：`flex-wrap: wrap` 已移除（原設定）
   —— 它會在手機（輸入框 width:100%）把 `N / N` 計數擠到下一行、多佔一列高度。
   改成 nowrap ＋ align-items:center，讓「輸入框 ｜ 計數」永遠同一行且垂直置中。 */
.tag-input-wrap--form { margin-left: 0; flex-wrap: nowrap; align-items: center; gap: 6px; }
/* ❗ 2026-10-25：chips 區右側的輸入框組（創作者｜標籤）
   —— 整組靠右（`margin-left:auto`），組內兩個輸入框緊鄰（gap 8px）。
      這樣創作者輸入框就會**緊貼在標籤輸入框的左邊**。 */
/* ❗ 2026-10-28：輸入列改成**自己一列、靠左**。
   原本 `margin-left:auto; justify-content:flex-end` 會在小標籤換行時把輸入框推歪
   （使用者回報第 7 點：「創作者輸入框位置會歪掉變成往左靠」）。
   PC 順序＝社團｜創作者｜標籤；手機在下面的 @media 改成上下堆疊。 */
.chips-inputs {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
}
.chips-inputs .tag-input-wrap { margin-left: 0; }

/* ❗ 2026-11-01：篩選列（社團／創作者／標籤）＝「輸入框 ＋ N/N 計數」同一行。
   三個 wrap 統一規則（原本只有 maker/creater 有 `--form`，genre 沒有 ⇒ 手機行為不一致）：
   ・nowrap：計數不准被擠到下一行（省高度）
   ・align-items:center：計數與輸入框垂直置中
   ・min-width:0：讓輸入框可以縮，把寬度留給計數 */
.chips-inputs .tag-input-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.chips-inputs .tag-input-wrap > input[type=text] { flex: 1 1 auto; min-width: 0; }
/* PC：維持原本的輸入框寬度（200px／`--form` 170px），計數另外佔固定寬度 */
@media (min-width: 621px) {
  .chips-inputs .tag-input-wrap > input[type=text] { flex: 0 0 auto; }
}

/* 創作者輸入框比標籤輸入框短一點（它只是輔助篩選） */
.tag-input-wrap--form input[type=text] { min-width: 170px; }
/* 已選的創作者／社團（client-side，按下「篩選」前先看得見） */
.ac-picked-wrap { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ac-picked {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
.ac-picked-k {
  padding: 0 5px; border: 1px solid var(--line); border-radius: 4px;
  color: var(--fg2); font-size: 11px; line-height: 16px;
}
.ac-picked-k:empty { display: none; }
.ac-picked a { color: var(--muted); text-decoration: none; }
.ac-picked a:hover { color: var(--accent); }
/* ❗ 2026-10-26：「創作者 AND/OR」的**客戶端**切換鈕
   （伺服器端渲染的是 `.chip.chip-op`；這個只在「已選 ≥2 且還沒按篩選」時出現） */
.ac-op {
  display: inline-flex; align-items: center;
  background: var(--bg3); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.ac-op:hover { background: var(--accent); color: var(--bg); }
.ac-op:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-input-wrap input[type=text] {
  background: var(--bg3); color: var(--fg);
  border: 1px dashed #3a4050; border-radius: 999px;
  padding: 5px 14px; font-size: 12px; min-width: 200px;
}
.tag-input-wrap input[type=text]:focus {
  outline: none; border-color: var(--accent); border-style: solid;
}
.tag-input-wrap .ac-list { left: auto; right: 0; min-width: 240px; }
.mini-noimg { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 6px; background: var(--bg3); }

/* ------------------------------ 語言版本（第 8 行）------------------------------ */
.card-mid .m8 { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.card-mid .m8 .k {
  display: inline-block; background: var(--bg3); border-radius: 4px;
  padding: 0 6px; font-size: 11px; color: var(--fg);
}

/* ------------------------------ 日夜模式切換 ------------------------------ */
.theme-toggle:hover { border-color: var(--accent); text-decoration: none; }

/* ------------------------------ 日間模式（[data-theme="light"]）------------------------------ */
/* ❗ 只覆寫變數就能整站換色 —— 不要寫第二份 CSS */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg2: #ffffff;
  --bg3: #eaecef;
  --line: #d6dae0;
  --fg: #1b1e23;
  --muted: #5c6470;
  --accent: #1c5fce;
  --good: #1554c0;      /* ❗ on --bg 6.29（原本 #1f6feb 只有 4.25，不合格） */
  --hot: #c0392b;
  --hidden: #9a5b00;
  --btn-primary: #1c5fce;   /* 白字 5.87，合格 */
  --ok: #0b7a4b;
  --warn: #9a5b00;
}
[data-theme="light"] .hdr { background: rgba(255, 255, 255, .92); }
[data-theme="light"] .card-thumb,
[data-theme="light"] .mini img { background: #e9ebee; }
[data-theme="light"] .price strong { color: #c0392b; }
[data-theme="light"] .stars { color: #e0a020; }
[data-theme="light"] .stars-empty { color: #b8bfc8; }
[data-theme="light"] .badge { background: var(--bg3); color: var(--muted); }
[data-theme="light"] .badge-top { background: #fff2cc; color: #8a6100; }
[data-theme="light"] .tag { background: var(--bg3); }
[data-theme="light"] .tag:hover { background: #dde3ec; }
[data-theme="light"] .ac-list { box-shadow: 0 8px 24px rgba(0, 0, 0, .15); }
[data-theme="light"] .age-gate { background: rgba(240, 242, 245, .96); }
[data-theme="light"] .empty,
[data-theme="light"] .tag-row { background: var(--bg2); }
[data-theme="light"] .score { color: var(--ok); }

/* ------------------------------ 標籤熱度卡片（v1.9 重新設計）------------------------------
   設計理由（使用者 2026-10-24）：
     「多色塊填滿之後變得不太好看，日/夜模式下所有文字都變得不顯眼，
       也無法直覺判斷色塊是什麼標籤」
   ⇒ ① 不再把顏色鋪滿卡片背景 —— 文字永遠在實色背景上
      ② 色塊縮成一條 6px 細長條，放在卡片最下方
      ③ 顏色一律與「名稱」成對出現（色點 + 分類名 + 數字），色條永遠有對照
   ---------------------------------------------------------------------------- */
.tag-row {
  position: relative;
  overflow: visible;              /* 不再裁切（舊版是為了鋪滿色塊才 hidden） */
  padding-bottom: 14px;           /* 留給下方細長條 */
}

/* 第一行：序號 ｜ 標籤名 ｜ 作品數 ………… 銷量 */
.tag-row .in { position: relative; display: flex; align-items: baseline; gap: 12px; }
.tag-row .no {
  width: 32px; text-align: right; color: var(--accent);
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.tag-row .nm { font-size: 14px; font-weight: 600; }
.tag-row .works {
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.tag-row .sales {
  margin-left: auto; font-variant-numeric: tabular-nums;
  color: var(--ok); font-weight: 700;
  /* ❗ 2026-12-05：固定寬度＋右對齊 —— 否則「銷量」位數不同會把後面的 spark／前期比
     一列一列往左推，看起來就沒對齊 */
  min-width: 104px; text-align: right; white-space: nowrap;
}

/* 第二行：色點 + 分類名 + 近 90 天作品數 */
.tag-row .sub {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-top: 6px; padding-left: 44px;       /* 對齊標籤名 */
}
.tag-row .sitepart {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.tag-row .sitepart .dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 8px; display: inline-block;
}
.tag-row .sitepart b {
  /* ❗ 同上：不用 opacity，改用字重區分 */
  color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums;
}

/* 下方細長條：外層是軌道，.fill 代表該標籤的相對分數，內部 .seg 是各分類占比 */
.tag-row .meter {
  position: absolute; left: 0; right: 0; bottom: 4px;
  height: 6px; border-radius: 3px;
  background: var(--bg3); overflow: hidden;
}
.tag-row .meter .fill { display: flex; height: 100%; }
.tag-row .meter .seg { height: 100%; display: block; }

/* 日間模式：細長條淡一點，避免刺眼 */
[data-theme="light"] .tag-row .meter { background: #e3e6ea; }
[data-theme="light"] .tag-row .meter .seg { opacity: .9; }

/* ------------------------------ 頁首控件統一（日夜模式 / 語系下拉）------------------------------
   ❗ 使用者 2026-10-24：「日夜模式按鈕 與 語系下拉選單 的視覺不統一」
   根因：`.lang-sel` 的樣式在某次重寫 CSS 時被截掉 → 語系下拉其實是
        **完全沒有樣式的原生 <select>**（沿用瀏覽器預設外觀）。
   ⇒ 兩者用同一組盒子：同高、同圓角、同邊框、同底色、同字級、同行高。
      下拉額外把原生箭頭關掉、自己畫一個，這樣跨瀏覽器才長一樣。
   ---------------------------------------------------------------------------- */
.theme-toggle,
.lang-sel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg3);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

/* 下拉：關掉原生外觀，留右側空間給自畫箭頭 */
.lang-sel {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 26px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) center, calc(100% - 9px) center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  background-color: var(--bg3);
}

.theme-toggle:hover,
.lang-sel:hover { border-color: var(--accent); text-decoration: none; }
.theme-toggle:focus-visible,
.lang-sel:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.theme-toggle .ico { font-size: 13px; line-height: 1; }

/* 檔案大小（卡片第 4 行下方） */
.card-mid .m9 { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-mid .m9 .k {
  display: inline-block; background: var(--bg3); border-radius: 4px;
  padding: 0 6px; margin-right: 6px; font-size: 11px; color: var(--fg);
}

/* ============================================================================
   品牌（HERO ASMR）
   品牌色取自 logo 素材：#0080ff 藍（36%）、#ff0000 紅（23%）、白（22%）
   ============================================================================ */
.brand { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand-ico {
  width: 28px; height: 28px; border-radius: 6px; display: block;
  /* 圖示本身是藍底，圓角是為了跟深色主題融合 */
}
.brand-tx { font-size: 17px; font-weight: 900; letter-spacing: .02em; line-height: 1; }
.brand-hero { color: #ff0000; }
.brand-asmr { color: #0080ff; margin-left: .22em; }
[data-theme="light"] .brand-asmr { color: #0069d9; }

/* ============================================================================
   響應式（RWD） —— 依 Google PageSpeed / Lighthouse 的建議
   ① 觸控目標至少 44×44 CSS px
   ② 不要讓內容造成水平捲動
   ③ 斷點：1180 / 900 / 620（既有）＋ 這次補的微調
   ============================================================================ */

/* 任何情況都不該出現水平捲動
   ❗❗ 一定要用 `overflow-x: clip`，不能只寫 `hidden`（2026-10-25 修正）：
     `overflow-x: hidden` 會讓 <body> 變成**捲動容器**，於是 `.hdr` 的
     `position: sticky` 只黏在 body 內（body 高度＝內容高度）⇒ 頁首根本不會固定，
     而是隨頁面一起捲走。`clip` 只裁切、不建立捲動容器，sticky 才會對視窗生效。
     保留 `hidden` 一行當舊瀏覽器（Safari < 16）的退路：那些瀏覽器 sticky 仍失效，
     但至少不會出現水平捲動。 */
html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }

/* ------------------------------ 回到頂部 ------------------------------ */
/* ❗ z-index 40 < .hdr 的 50 ⇒ 捲到頁首附近時不會蓋住頁首；
   > 內文（沒有 z-index）⇒ 一定看得見。
   44×44 是觸控目標下限；`:focus-visible` 給鍵盤使用者清楚的焦點框。 */
.to-top {
  position: fixed; right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg2); color: var(--fg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.to-top.is-on { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--bg3); color: var(--fg); text-decoration: none; }
.to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 700px) {
  .to-top { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .to-top { transition: none; transform: none; }
}

/* ---------- ≤ 1180px：右欄（分數/星數）縮一點 ---------- */
@media (max-width: 1180px) {
  .card-right { flex: 0 0 128px; }
}

/* ---------- ≤ 900px：平板 ---------- */
@media (max-width: 900px) {
  .hdr-in { gap: 10px; }
  .nav { gap: 2px; }
  .card-main { gap: 10px; }
  /* 篩選改成 2 欄，避免橫向捲動 */
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .filters label { grid-column: auto; }
  .filters select { width: 100%; }
  .filters-kw { grid-column: 1 / -1; }
  /* ❗ `.ff` 是 flex row（label 在左）⇒ select 要吃滿剩下的寬度 */
  .ff { min-width: 0; }
  .ff select { flex: 1 1 auto; }
  /* 觸控目標 */
  /* ❗ 表單用的是 <button class="btn">，不是 input[type=submit] ⇒ 要另外列。 */
  .filters select, .filters input[type="submit"], .filters .btn,
  .theme-toggle, .lang-sel { min-height: 40px; }
}

/* ---------- ≤ 620px：手機 ---------- */
/* ❗ chobit 的 `.sp`（手機版型）是**伺服器端依 User-Agent 決定**的 ——
   用手機 UA 抓 embed 頁會直接得到 `<div class="player-box audio embed sp">`。
   所以真手機拿到的是響應式版型，只要 iframe 寬度跟著容器就會正確重排。

   高度：`.embed.sp .audio-wrapper { min-height: 172px }`，
   但 `<ol>` 播放清單仍佔 98px，實際會超過 172 ⇒ 給 220（iframe 內是播放器自己的
   深色底，多出來只是背景，不會有突兀的空白）。 */
@media (max-width: 700px) {
  /* ❗ 改的是 stage 的高度（facade 與 iframe 都吃 100%），才會前後一致、零 CLS */
  .embed-stage { height: 220px; }
}

@media (max-width: 620px) {
  /* ❗ 手機上關掉 backdrop-filter：sticky header 的毛玻璃在滾動時每幀都要重新合成，
     是移動版 Speed Index 的常見元兇。背景本來就 92% 不透明，看起來幾乎沒差。 */
  .hdr { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .age-gate { backdrop-filter: none; -webkit-backdrop-filter: none; }

  /* 頁首：品牌 + 控件換行，不擠成一條 */
  .hdr-in { flex-wrap: wrap; height: auto; padding: 8px 0; gap: 8px; }
  /* ❗ 2026-10-26：nav 縮小讓 6 項塞進 360px（原本會溢出成橫向卷軸）。
     真的還溢出時（≤320px）把卷軸藏起來 —— 仍可滑動，只是不露出醜醜的條。 */
  .nav {
    order: 3; flex: 1 1 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 2px; scrollbar-width: none; -ms-overflow-style: none;
  }
  .nav::-webkit-scrollbar { display: none; height: 0; }
  .nav-a { padding: 5px 9px; font-size: 12px; }
  /* 手機：只顯示短名 */
  .nav-f { display: none; }
  .nav-s { display: inline; }
  .brand-tx { font-size: 15px; }

  /* 卡片：改成「縮圖在上、資訊在下」的單欄 */
  .card-main { flex-direction: column; align-items: stretch; gap: 8px; }
  .card-thumb-wrap { width: 100%; }
  .card-thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; }
  .card-mid { width: 100%; }
  /* 右欄（分數/星數）變成橫向一排 */
  .card-right {
    flex: 0 0 auto; width: 100%;
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
    border-left: none; border-top: 1px solid var(--line); padding: 8px 0 0;
  }
  /* ❗ 2026-10-28（使用者第二輪回報）：放右上角「非常不明顯」。
     要求：**放在分站小標籤的左邊，而且要比分站小標籤更顯眼**。
     ⇒ 左上角、琥珀色底＋深色粗字（與藍色分站標籤形成強對比），
        再由 `data-rank-len` 把 `.site-badge` 往右讓位（見下方）。
     ❗ 為什麼不用 flex 併排：`.rank-no` 在 `.card`、`.site-badge` 在 `.thumb-link`，
        兩者父層不同（座標系差 10px），CSS 無法跨父層對齊。 */
  /* ❗ 2026-10-28（使用者第四輪）：要和分站小標籤「同高、同一條水平線」，
     而且 left:10px 看起來貼著圖片邊緣 ⇒ 改成 20px（圖片左緣在 card X=10）。
     座標系差異：`.rank-no` 相對 `.card`，`.site-badge` 相對 `.thumb-link`（多 10px）。
     高度統一 22px，兩者都 `inline-flex` 垂直置中。 */
  .rank-no {
    left: 20px; top: 18px; right: auto;
    width: auto; min-width: 26px;
    height: 22px; padding: 0 9px;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1;
    text-align: center; border-radius: 6px;
    font-size: 14px; font-weight: 800;
    background: #ffc247; color: #2a1a00;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .55);
    z-index: 4;
  }
  /* 分站＋R15 標籤容器：同一條水平線（card Y=18，圖片內縮 8px）、同樣 22px 高
     ❗ 2026-10-29（使用者）：R15 標籤要在分站標籤右側緊靠 ⇒ 定位改由容器負責，
        兩個標籤在容器內 flex 併排（`.site-badge` / `.age-badge` 都改成 static 高度 22px）。 */
  .thumb-badges {
    top: 8px; height: 22px;
  }
  .site-badge {
    height: 22px; padding: 0 9px;
    display: inline-flex; align-items: center;
    line-height: 1;
  }
  /* ❗ 高度維持 22px（要與左邊的名次標籤同一條水平線），
     但字級放大到 14px／800 ⇒ 比站台標籤的 12px 更顯眼。 */
  .age-badge {
    height: 22px; padding: 0 8px;
    display: inline-flex; align-items: center;
    line-height: 1; font-size: 14px; font-weight: 800;
  }
  /* 讓位：容器 left（thumb 座標）= 18 + rank 寬度
     rank 寬度 ≈ 18(padding) + 7.8 × 位數（14px/800）⇒ 4 種位數各給一個值，間距 8px */
  .card[data-rank-len="1"] .thumb-badges { left: 44px; }
  .card[data-rank-len="2"] .thumb-badges { left: 52px; }
  .card[data-rank-len="3"] .thumb-badges { left: 60px; }
  .card[data-rank-len="4"] .thumb-badges { left: 68px; }
  .card { padding: 10px; }

  /* 篩選：**2 欄**，每個 `.ff` 一列「label 上、select 下」
     ⇒ 6 個篩選 = 3 列（原本單欄 12 列，一進頁面全是篩選）。
     ❗ 觸控目標維持 44px 高（PSI 手機易用性）。
     ❗ label 雖然只有約 18px 高，但寬度是整個欄寬（>48px）；
        Lighthouse 的 tap-target 判定是「**兩個維度都小於 48px** 才算不合格」⇒ 不會被扣分。 */
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 10px; }
  .ff { flex-direction: column; align-items: stretch; gap: 3px; }
  .ff label { font-size: 11px; line-height: 1.3; }
  .filters select,
  .filters .btn { min-height: 44px; font-size: 15px; }
  .ff select { width: 100%; }
  .filters .btn { padding: 6px 16px; width: 100%; text-align: center; }
  .theme-toggle, .lang-sel { min-height: 40px; }

  /* 標籤卡片：第二行分類會換行 */
  .tag-row .in { flex-wrap: wrap; gap: 6px 10px; }
  /* ❗ 2026-10-29（使用者回報）：手機版這裡原本寫 `margin-left: 0`，
     導致「銷量 xxx,xxx」緊貼在「作品數」後面（往左靠）。
     改成 `margin-left: auto` ⇒ 與 PC 版一致，靠卡片右側。
     ❗ 首頁與標籤熱度頁共用 `render_tag_row()`，改這裡兩邊同時生效。 */
  .tag-row .sales { margin-left: auto; }
  .tag-row .sub { padding-left: 0; }
  .tag-row .nm { font-size: 13.5px; }

  /* 標籤頁的 chips（已套用的篩選） */
  .chips-row { gap: 8px; }
  .chips-row .chip { font-size: 12px; }
  /* ❗ 2026-10-28：手機版輸入框**上下堆疊**，社團在最上面
     （DOM 順序 maker → creater → genre，所以不用改順序）。 */
  .chips-inputs { flex-direction: column; align-items: stretch; }
  .chips-inputs .tag-input-wrap { width: 100%; }
  /* ❗ 2026-11-01：原本 `width:100%` 會把 `N / N` 計數擠到下一行；
     改成彈性寬度（吃掉剩下的空間），計數就留在同一行。 */
  .chips-inputs .tag-input-wrap input[type=text] { width: auto; flex: 1 1 auto; min-width: 0; }
  .chip-groups { flex-direction: column; align-items: stretch; }
  .chip-group { width: 100%; }
}

/* ---------- ≤ 380px：超小螢幕 ---------- */
@media (max-width: 380px) {
  .brand-tx { font-size: 13.5px; }
  /* ❗ 320px 寬的手機：nav 再縮一級 */
  .nav-a { padding: 4px 7px; font-size: 11.5px; }
  .card-right { font-size: 12px; }
}

/* ---------- 減少動態（無障礙）---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 只給螢幕閱讀器的文字（無障礙 + Lighthouse A11y）---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================================
   問題回報頁（contact.php）
   ============================================================================ */
.contact-form {
  max-width: 720px; margin: 24px auto 48px;
  display: flex; flex-direction: column; gap: 6px;
}
.contact-form label { font-size: 13px; font-weight: 600; color: var(--fg); margin-top: 14px; }
.contact-form .req { color: #ff5c5c; }
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form select,
.contact-form textarea {
  box-sizing: border-box; width: 100%;
  padding: 10px 12px; min-height: 44px;          /* 觸控目標 */
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 15px; line-height: 1.5;
}
.contact-form textarea { min-height: 180px; resize: vertical; }
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.contact-form .hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.contact-form .hint.small { font-size: 11px; margin-top: 16px; }

/* honeypot：真人看不到，但要讓機器人「看得到」 */
.contact-form .hp {
  position: absolute !important; left: -9999px !important;
  width: 1px; height: 1px; overflow: hidden;
}

/* 提示區塊 */
.notice {
  max-width: 720px; margin: 16px auto; padding: 12px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg2);
  font-size: 14px; line-height: 1.7;
}
.notice ul { margin: 0; padding-left: 20px; }
.notice.ok   { border-color: #2e7d32; background: rgba(46, 125, 50, .12); }
.notice.err  { border-color: #c62828; background: rgba(198, 40, 40, .12); }
.notice.info { border-color: var(--line);  background: var(--bg3); color: var(--muted); }

/* 按鈕 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 20px; margin-top: 18px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg3); color: var(--fg);
  font-size: 15px; font-weight: 600; cursor: pointer;
  align-self: flex-start;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--btn-primary); border-color: var(--btn-primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

/* 說明頁的 CTA 區塊 */
.cta {
  max-width: 720px; margin: 32px auto 56px; padding: 20px 22px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg2);
  text-align: center;
}
.cta p { color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.cta .btn { align-self: auto; }

@media (max-width: 620px) {
  .contact-form { margin: 16px 12px 32px; }
  .contact-form input, .contact-form select, .contact-form textarea { font-size: 16px; }
  .cta { margin: 24px 12px 40px; padding: 16px; }
}

/* 淺色主題下 primary 按鈕的白字對比要夠 */
/* `--btn-primary` 已分主題定義，不需要再覆寫 */

/* 友站連結（說明頁）：banner 預覽 + 可複製的 HTML 區塊
   ❗ 使用者 2026-10-25：banner 隨介面語言切換（ja / zh_TW / en 三張圖） */
.friends { margin-top: 4px; }
.friends-banner { margin: 12px 0 10px; }
.friends-banner img { display: block; width: 300px; height: 96px; border-radius: 8px; }
.friends-note { font-size: 12.5px; line-height: 1.6; color: var(--fg-2); }
.friends-note code { font-size: 11px; }
.friends-code {
  margin: 10px 0 0; padding: 12px 14px; overflow-x: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  font-size: 11px; line-height: 1.7; color: var(--muted);
  white-space: pre-wrap; word-break: break-all;
}
.friends-code code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
@media (max-width: 420px) {
  .friends-banner img { width: 100%; height: auto; }
}

/* ==========================================================================
   友站清單卡片 v4（2026-10-31 第四輪定案）
   ┌────────────────────┐
   │ 網站標題    [範例]  │  標題列（底下有分隔線）
   ├────────────────────┤
   │    ▓ banner 300 ▓   │  banner 在卡片內**置中**，四周留 12px 外框
   ├────────────────────┤
   │ 網站說明（2 行）    │  說明列（line-clamp 2，固定高度對齊）
   └────────────────────┘

   ・PC（≥780px）：**一列兩欄**，每張卡 358px
     剩餘空間平均分給「左邊界 / 欄間隙 / 右邊界」⇒ 三者相等
   ・手機（<780px）：1 欄，卡片在內容區**置中**
   ・banner 一律 300×96 **原尺寸**（放大會糊），在卡片內水平置中
   ❗ 上一版誤解使用者語意：把「banner 置中」做成「PC 卡片置中」＋卡片加寬到 428px，
     導致 banner 兩側各 64px 空白。本版已修正。
   ========================================================================== */
.friends-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* 手機：1 欄 */
  justify-items: center;                   /* 卡片在欄內置中 */
  gap: 18px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.friends-card {
  width: 100%;
  max-width: 358px;                        /* 與手機版同寬 */
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  overflow: hidden;
  margin: 0;
}
.friends-card.is-broken { display: none; }

/* ① 標題列 */
.friends-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 38px;
  box-sizing: border-box;
}
.friends-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.friends-card-title:hover { color: var(--accent); }

/* ② banner 列：卡片內置中 + 12px 外框 */
.friends-card-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  line-height: 0;
}
.friends-card-banner img {
  display: block;
  width: 300px;              /* 原尺寸：不放大才不糊 */
  max-width: 100%;
  height: auto;
}

/* ③ 說明列（最高兩行；固定高度讓卡片底部對齊） */
.friends-card-desc {
  margin: 0;
  padding: 10px 12px;
  /* ❗ 2026-10-31：說明是「要讀的內容」⇒ 用 --fg-2（約 10:1），不用裝飾用的 --muted */
  font-size: 12.5px;
  color: var(--fg-2);
  /* ❗ 固定「剛好兩行」的高度。
     ⚠ 站上有 `* { box-sizing: border-box }` ⇒ `height` 是**含 padding** 的！
        先前寫 `height: calc(1.65em * 2)`（41.25px）會被上下 padding 20px 吃掉，
        內容只剩約一行（使用者回報「連第二行都被卡掉」）。
     ⇒ 高度 = 2 行 + 上下 padding；並把 line-height 改成整數 20px，
        消除 20.625px 的亞像素誤差（否則第二行底部可能被切掉 0.75px）。
     這樣：內容區剛好 40px = 2 行，第 3 行從 40px 才開始 ⇒ 不可能露出來；
     短文字也佔同樣高度，卡片底部照樣對齊。 */
  height: 60px;              /* 20px × 2 行 + 10px × 2 padding */
  line-height: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 「範例」膠囊（空狀態）：標題列右側 */
.friends-card-sample {
  flex: 0 0 auto;
  padding: 0 8px;
  border-radius: 999px;
  background: #ffc247;
  color: #2a1a00;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  letter-spacing: .3px;
  white-space: nowrap;
}

.friends-empty { color: var(--fg-2); font-size: 13px; line-height: 1.65; margin: 8px 0 12px; }

/* PC：一列兩欄；左右留白與欄間隙三者相等 */
@media (min-width: 780px) {
  .friends-list {
    /* 808 − 2×358 = 92 ⇒ 92/3 ≈ 30.67，三者相同 */
    --friends-gap: calc((100% - 716px) / 3);
    grid-template-columns: repeat(2, minmax(0, 358px));
    justify-content: space-between;
    justify-items: stretch;
    /* ❗ 2026-11-03（使用者回報「兩列卡片的上下間隔太小」）：
       `gap` 的百分比在 **row 軸** 會對容器高度（auto）解析 ⇒ 變成 0
       ⇒ 原本的 `gap: var(--friends-gap)` 只有「欄間距」有效，「列間距」幾乎是 0。
       ⇒ 拆成 column-gap（百分比，隨寬度自適應）＋ row-gap（固定 18px，與手機版一致）。 */
    column-gap: var(--friends-gap);
    row-gap: 18px;
    padding-inline: var(--friends-gap);
  }
}

/* 分頁 */
.friends-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.friends-pager button {
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}
.friends-pager button:hover { border-color: var(--accent); }
.friends-pager button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.friends-pager button:disabled { opacity: .4; cursor: default; }

/* ==========================================================================
   篩選輸入框「已達上限」狀態（2026-11-01）
   ・為什麼要：上限原本是伺服器靜默截斷，使用者打到第 4 個社團會被偷偷刪掉
   ・這裡只做「看得出來」：灰底 + 虛線框 + 禁止游標；手機沒有 hover，靠顏色區分
   ========================================================================== */
.filter-ac.is-maxed,
.filter-ac:disabled {
  background: var(--bg3);
  color: var(--muted);
  border-color: var(--line);
  border-style: dashed;
  cursor: not-allowed;
  opacity: .75;
}
.filter-ac.is-maxed::placeholder,
.filter-ac:disabled::placeholder { color: var(--muted); }

/* ==========================================================================
   N / N 計數（2026-11-01 改版，使用者回報「沒對齊、手機斷行」）
   ・與輸入框**同高**：align-self:stretch ⇒ 盒子高度 = 輸入框高度（5+5 padding +
     12px 字 + 2 border ≈ 30px），文字在其中垂直置中
   ・與輸入框**同一行**：父層 nowrap（見 .chips-inputs .tag-input-wrap）
   ・**寬度固定**：min-width 用 ch（`0 / 3` 到 `99 / 99` 都是 7ch）＋ tabular-nums
     ⇒ 數字從 0→3 或 9→10 都不會變寬、不會把版面擠到換行
   ========================================================================== */
.filter-count {
  flex: 0 0 auto;                 /* 不壓縮、不被輸入框擠掉 */
  align-self: stretch;            /* 與輸入框同高 */
  display: inline-flex;
  align-items: center;            /* 文字在框內垂直置中 */
  justify-content: center;        /* 文字在框內水平置中 */
  min-width: 7ch;                 /* 固定寬度（最大 99 / 99） */
  margin-left: 0;
  font-size: 12px;                /* 與輸入框字級一致 */
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.filter-count.is-maxed { color: #ffb454; font-weight: 700; }

/* 超限提示（網址硬塞超過上限時顯示一次） */
.filter-trim-notice {
  margin: 6px 0 2px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg-2);
  background: var(--bg3);
  border: 1px dashed var(--line);
  border-radius: 6px;
}
.friends-pager .fp-nums { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* ==========================================================================
   可讀性：次要文字專用色（2026-10-31）
   ❗ 不改全站 `--muted`（那是裝飾性灰，很多地方靠它降調）；
     這裡只給「使用者真的要讀」的文字用，兩主題都拉到約 10:1 對比。
       深色：--fg-2 #c8ccd4 on #1b1e24 ≈ 10.4:1
       淺色：--fg-2 #39404a on #ffffff ≈ 10.5:1
   ========================================================================== */
:root { --fg-2: #c8ccd4; }
[data-theme="light"] { --fg-2: #39404a; }

/* ==========================================================================
   作品詳情頁（/work/{workno}）— P1-1 骨架
   ・P1-2 會把上半段改成排行頁 card-main 的結構，這裡先給「不破版」的最小樣式
   ========================================================================== */
.work-detail {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin: 8px 0 24px;
}
.work-detail-img img {
  width: 100%; height: auto; display: block;
  border-radius: 8px; border: 1px solid var(--line);
}
.work-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.6;
}
.work-facts dt { color: var(--muted); }
.work-facts dd { margin: 0; color: var(--fg); }

.work-scores { margin: 14px 0; }
.work-scores-h { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.work-scores ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.work-scores li {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 10px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 12px; background: var(--bg3);
}
.work-scores .wk { color: var(--muted); }
.work-scores .sc { font-weight: 700; font-variant-numeric: tabular-nums; }
.work-scores .rk { color: var(--muted); font-variant-numeric: tabular-nums; }

.work-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.work-creaters { font-size: 12px; color: var(--fg-2); margin: 8px 0; }
.work-detail .btn-dl {
  display: inline-block; margin-top: 10px; padding: 8px 20px;
  border-radius: 999px; background: var(--accent); color: var(--bg);
  font-weight: 700; text-decoration: none;
}
.work-detail .btn-dl:hover { opacity: .9; }

@media (max-width: 620px) {
  .work-detail { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .work-detail-img { max-width: 320px; }
}

/* ==========================================================================
   作品頁 P1-2：card-right 的「各排行分數與名次」
   ・排行頁的 card-right 最上方只有一個分數；作品頁是 1~4 行
   ・數字用 tabular-nums ＋ 固定寬度，避免手機上寬度跳動（P1-4 會再統一）
   ========================================================================== */
.card[data-no-rank] { padding-left: 16px; }

.scores-multi {
  display: flex; flex-direction: column; gap: 2px;
  margin-bottom: 6px;
}
.sm-row {
  display: grid;
  grid-template-columns: minmax(3.2em, auto) minmax(4.2ch, 1fr) minmax(5ch, auto);
  align-items: baseline; gap: 6px;
  font-size: 12px; line-height: 1.45;
}
.sm-k { color: var(--muted); }
.sm-s {
  font-weight: 700; text-align: right;
  font-variant-numeric: tabular-nums;
}
.sm-r {
  color: var(--muted); text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   作品頁 P1-3：同社團／同聲優 清單區塊
   ========================================================================== */
.work-section { margin: 28px 0 8px; }
.work-section-h {
  font-size: 16px; font-weight: 800; letter-spacing: .02em;
  margin: 0 0 12px; padding: 2px 0 2px 10px;
  border-left: 4px solid var(--accent);
  color: var(--fg);
}

/* 分頁（只在 PC 顯示；JS 會依 media query 切換 hidden） */
.mini-pager {
  display: none; align-items: center; gap: 10px;
  margin-top: 12px;
}
@media (min-width: 621px) {
  .mini-pager { display: flex; }
  .mini-pager[hidden] { display: none; }
}
.mini-pager button {
  border: 1px solid var(--line); background: var(--bg2); color: var(--fg);
  border-radius: 8px; padding: 3px 11px; font-size: 15px; line-height: 1.5;
  cursor: pointer;
}
.mini-pager button:hover:not(:disabled) { border-color: var(--accent); }
.mini-pager button:disabled { opacity: .35; cursor: default; }
.mini-pageinfo {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ❗ `.mini` 是 display:flex，會蓋掉 [hidden] 的 display:none ⇒ 必須自己補一條 */
.work-section .mini[hidden] { display: none; }

/* 沒有縮圖時的預設圖（DLsite 官方缺圖，已轉成本站 64×64 webp） */
/* ❗ 一定要補這條：`.mini img` 的 display 會蓋掉 UA 的 [hidden]{display:none} */
.mini-noimg[hidden] { display: none !important; }
.mini-noimg {
  width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: 6px; background: var(--bg3);
  object-fit: contain; padding: 4px; box-sizing: border-box;
  opacity: .75;
}

/* ==========================================================================
   card-right 重設計（2026-11-01 使用者規格 6／7）
   --------------------------------------------------------------------------
   ① 右欄 168px → 128px（badges 最寬 124，避免過寬）
   ② 多榜單分數（作品頁）：靠右收斂，名次做成小膠囊
   ③ 星星 15px、評分數字 12px（不再用 <small>）
   ④ 四個數量：數字固定 5 寬、右對齊（不足自動補齊視覺寬度）
   ⑤ badges：膠囊等寬（PC 直排、手機同一列）
   ⑥ 手機：四個數量同一列、badges 同一列，間隙（含左右邊）一律 4px
   ========================================================================== */
.card-right { flex: 0 0 128px; width: 128px; }

/* ② 多榜單 */
.scores-multi {
  display: flex; flex-direction: column; gap: 2px;
  margin-bottom: 6px;
}
.sm-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline; column-gap: 6px;
  font-size: 12px; line-height: 1.5;
}
.sm-k { color: var(--muted); }
.sm-s { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.sm-r {
  color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums;
  background: var(--bg3); border-radius: 999px; padding: 0 6px;
}

/* ③ 星星 / 評分數字 */
.card-right .stars, .card-right .stars-empty { font-size: 15px; letter-spacing: 0; }
.card-right .stars-line {
  display: flex; align-items: baseline; justify-content: flex-end; gap: 4px;
}
.card-right .rate-num { font-size: 12px; font-variant-numeric: tabular-nums; }

/* ④ 四個數量 */
.card-right .counts {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
}
.card-right .counts .k { color: var(--muted); }
.card-right .cnt {
  min-width: 5ch; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--fg);
}

/* ⑤ badges 等寬 */
.card-right .badges { display: grid; grid-template-columns: 1fr; gap: 3px; width: 100%; }
.card-right .badge { text-align: center; white-space: nowrap; }

/* ⑥ 手機：兩個「同一列」 */
@media (max-width: 620px) {
  .card-right {
    flex: 0 0 auto; width: 100%;
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 6px; text-align: left;
    border-top: 1px solid var(--line);
    padding: 8px 0 0; margin-top: 8px;
  }
  .card-right .scores-multi { width: 100%; margin-bottom: 0; }
  .sm-row { grid-template-columns: auto auto auto; justify-content: start; column-gap: 8px; }
  .sm-s { text-align: left; }

  /* 四個數量：同一列、等寬欄位（間隙 ＋ 左右邊都是 4px） */
  .card-right .counts-row {
    width: 100%;
    display: flex; gap: 4px;
    padding: 0 4px;
    box-sizing: border-box;
  }
  .card-right .counts {
    flex: 1 1 0; min-width: 0;
    flex-direction: column; align-items: center; gap: 0;
    text-align: center;
  }
  .card-right .counts .k { font-size: 10px; line-height: 1.3; }
  .card-right .cnt { min-width: 0; font-size: 12px; font-weight: 700; }

  /* badges：同一列、等寬膠囊、4 個間隙等寬 */
  .card-right .badges {
    width: 100%;
    display: flex; gap: 4px;
    padding: 0 4px;
    box-sizing: border-box;
  }
  .card-right .badge {
    flex: 1 1 0; min-width: 0;
    text-align: center; font-size: 10px; padding: 1px 0;
    overflow: hidden; text-overflow: ellipsis;
  }
  /* 只有 1 個膠囊時不要拉成全寬（置中即可） */
  .card-right .badges[data-n="1"] .badge { flex: 0 1 auto; padding: 1px 10px; }
}

/* mini 清單的「目前瀏覽／總數」只在手機顯示（第 4 項） */
.mini-count { display: none; }
@media (max-width: 620px) {
  .mini-count {
    display: block;
    text-align: right;
    font-size: 11px; color: var(--muted);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
  }
}

/* ==========================================================================
   第二輪 UI 規格（第 1、2、3、4、5、8、9 項）— 2026-11-01
   ========================================================================== */

/* ⑧ PC mini 清單：保留高度但**不要拉高卡片**（align-content 預設 stretch 會把列撐開） */
.mini-list { align-content: start; align-items: start; }

/* ②⑤ 星星成為 counts-row 的一員（PC：星星在左、評分在右） */
.card-right .stars-wrap { display: inline-flex; align-items: center; white-space: nowrap; }
.card-right .stars-line .stars,
.card-right .stars-line .stars-empty { font-size: 15px; letter-spacing: 0; }
.card-right .stars-line .rate-num { font-size: 12px; font-weight: 700; }

/* ③⑨ 多榜單分數（2026-11-01 改型）
   ・取消獨立的 sm-r 膠囊：名次直接接在榜單名後（「殿堂#1,936」）
   ・PC：sm-k 靠左、sm-s 靠右；整個 scores-multi 是小膠囊（圓角底色）與其他區塊區分
   ・手機：單列最多三個 sm-row，每個 sm-row 自己有膠囊，k／s 置中、中間隔一個全形 */
.scores-multi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 10px; margin-bottom: 6px;
  background: var(--bg3); border-radius: 10px;
}
.scores-multi .sm-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 12px; line-height: 1.5;
}
.scores-multi .sm-k { color: var(--muted); white-space: nowrap; }
.scores-multi .sm-no {
  color: var(--fg); font-weight: 700;
  font-variant-numeric: tabular-nums; margin-left: 2px;
}
.scores-multi .sm-s {
  font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums; color: var(--fg);
  white-space: nowrap;
}

/* ① 作品頁沒有名次膠囊 ⇒ 站台膠囊要靠左（排行頁仍保留 44~68px 的名次位移） */
.card[data-no-rank] .thumb-badges { left: 8px; }

@media (max-width: 620px) {
  /* ④ 多榜單（手機）：縮成「單列三格」，每格自己一個膠囊，間隙比照 badges */
  .card-right .scores-multi {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 0 4px;
    background: none; border-radius: 0;
    margin: 0 0 2px;
    width: 100%;
  }
  .card-right .sm-row {
    display: flex; align-items: baseline; justify-content: center;
    gap: 1em;                       /* k 與 s 之間隔一個全形 */
    min-width: 0;
    padding: 1px 4px;
    background: var(--bg3);
    border-radius: 999px;
    font-size: 11px;
  }
  .card-right .sm-k { font-size: 11px; }
  .card-right .sm-no { font-size: 11px; }
  .card-right .sm-s { font-size: 12px; }

  /* ⑤ counts-row：五個物件（星星 ＋ 四個數量）同列、等寬，間隙含左右邊一律 4px */
  .card-right .counts-row {
    width: 100%;
    display: flex; gap: 4px;
    padding: 0 4px;
    box-sizing: border-box;
  }
  .card-right .counts {
    flex: 1 1 0; min-width: 0;
    flex-direction: column; align-items: center; gap: 0;
    text-align: center;
  }
  .card-right .stars-line .stars,
  .card-right .stars-line .stars-empty { font-size: 10px; letter-spacing: 0; }
  .card-right .stars-line .rate-num { font-size: 12px; }
}

/* 對應語言（2026-11-01 使用者：每個 workno 一個小膠囊，整段是一個連結） */
.card-mid .m8 .ed-link,
.card-mid .m8 .ed-plain {
  display: inline-flex; align-items: center;
  padding: 0 8px; border-radius: 999px;
  background: var(--bg3);
  font-size: 11px; line-height: 1.9;
  white-space: nowrap;
}
.card-mid .m8 .ed-link {
  color: var(--accent); text-decoration: none;
}
.card-mid .m8 .ed-link:hover { color: var(--fg); background: var(--bg2); }
.card-mid .m8 .ed-plain { color: var(--muted); }
/* 多個膠囊之間留 5px（與 .m7 標籤一致） */

/* P1-5：卡片置底「查看作品詳情」（站內連結） */
.card-mid .m10 { margin-top: 8px; }
.card-mid .detail-link {
  display: inline-block;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.card-mid .detail-link:hover { color: var(--fg); }

/* ---------------------------------------------------------------------------
   T-19（2026-11-07）：已下架作品的明顯標示
   --------------------------------------------------------------------------- */
.gone-notice{display:flex;gap:10px;align-items:flex-start;margin:0 0 14px;
  padding:12px 14px;border-radius:10px;line-height:1.55;
  background:rgba(220,38,38,.12);border:1px solid rgba(220,38,38,.45);color:#fca5a5}
html[data-theme="light"] .gone-notice{background:#fef2f2;border-color:#fca5a5;color:#991b1b}
.gone-notice .gone-ico{font-size:1.15em;line-height:1.2}
.gone-notice .gone-tx strong{display:inline-block;margin-right:6px;
  padding:1px 8px;border-radius:6px;background:rgba(220,38,38,.85);color:#fff;font-size:.92em}

/* ------------------------- 排行膠囊（作品頁） ------------------------- */
/* 尺寸：card-right 128px（≤1180px）⇒ 膠囊 128px ⇒ 扣掉左右內距 8px 後文字可用 112px
   （「殿堂#500 70.17」放得下）。PC 與手機都是單行。 */
.scores-multi {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 0; margin-bottom: 6px;
  background: none; border-radius: 0;
}
.scores-multi .sm-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 6px; min-width: 0;
  padding: 4px 8px; border-radius: 999px;
  background: var(--bg3); color: var(--fg);
  text-decoration: none;
  font-size: 16px; line-height: 1.35;
}
.scores-multi .sm-row .sm-k {
  color: var(--fg); font-size: 16px; white-space: nowrap;
}
.scores-multi .sm-row .sm-no {
  color: var(--fg); font-size: 16px; font-weight: 700;
  margin-left: 2px; font-variant-numeric: tabular-nums;
}
.scores-multi .sm-row .sm-s {
  color: var(--fg); font-size: 13px; font-weight: 700;
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* 前十名：badge-top 配色 */
.scores-multi .sm-row.has-top { background: #3d2f12; color: #ffc247; }
.scores-multi .sm-row.has-top .sm-k,
.scores-multi .sm-row.has-top .sm-no,
.scores-multi .sm-row.has-top .sm-s { color: #ffc247; }
[data-theme="light"] .scores-multi .sm-row.has-top { background: #fff2cc; color: #8a6100; }
[data-theme="light"] .scores-multi .sm-row.has-top .sm-k,
[data-theme="light"] .scores-multi .sm-row.has-top .sm-no,
[data-theme="light"] .scores-multi .sm-row.has-top .sm-s { color: #8a6100; }

/* hover 只給有滑鼠的裝置（手機點擊會卡在 :hover）*/
@media (hover: hover) and (pointer: fine) {
  .scores-multi .sm-row:hover { background: var(--bg2); }
  .scores-multi .sm-row.has-top:hover { background: #4b3a15; }
  [data-theme="light"] .scores-multi .sm-row.has-top:hover { background: #ffe9a8; }
}

/* 手機：三欄 grid、單行 */
@media (max-width: 620px) {
  .card-right .scores-multi {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px; padding: 6px 0;
    background: none; border-radius: 0;
  }
  .card-right .sm-row {
    width: auto; flex-direction: row; align-items: baseline;
    justify-content: space-between; gap: 6px; padding: 4px 8px;
  }
  .card-right .sm-row .sm-s { text-align: right; }
}


/* ==========================================================================
 * 作品頁擴充區塊（2026-11-14）：語言版本數據／排行表現／新作資訊／作品數據／本站觀察／mini 卡片
 * ========================================================================== */
.wt-block, .wt-editions { max-width: 1280px; margin: 22px auto; padding: 0 16px; }
.wt-block h2, .wt-editions h2 { font-size: 15px; margin: 18px 0 8px; }
.wt-block h6, .wt-editions p.desc { font-size: 13px; }
.wt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wt-table th, .wt-table td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: right; }
.wt-table th:first-child, .wt-table td:first-child { text-align: left; }
.wt-table thead th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.wt-scroll { overflow-x: auto; }
.wt-bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 2px 0; }
.wt-bar-k { width: 24px; color: var(--muted); }
.wt-bar { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.wt-bar i { display: block; height: 100%; background: var(--accent); }
.wt-bar-v { width: 120px; text-align: right; color: var(--muted); }

/* mini 卡片（B 案） */
.mp-block { margin: 18px auto; max-width: 1280px; padding: 0 16px; }
.mp-block h2 { font-size: 14px; margin: 0 0 8px; }
.mp-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mp-list .mp-card[hidden] { display: none !important; }
.mp-card { flex: none; min-width: 0; display: flex; gap: 8px; padding: 8px; border-radius: 10px;
           background: var(--bg2); border: 1px solid var(--line); }
.mp-card.mp-top { border-color: #ffc24788; }
.mp-thumb img, .mp-noimg { border-radius: 6px; object-fit: cover; display: block; width: 64px; height: 64px; background: var(--bg3); }
.mp-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.mp-title { font-size: 12.5px; line-height: 1.3; color: var(--accent); text-decoration: none;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-row2, .mp-row3 { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.mp-row2 .mp-maker { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-price { font-weight: 600; color: var(--fg); }
.mp-chip { border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.mp-score { font-weight: 700; color: var(--fg); font-size: 12.5px; }
.mp-sales { white-space: nowrap; }
.mp-more { margin-left: auto; color: var(--accent); text-decoration: none; white-space: nowrap; }
.mp-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.mp-pager button { border: 1px solid var(--line); background: var(--bg2); color: var(--fg); border-radius: 8px; padding: 3px 12px; font-size: 14px; cursor: pointer; }
.mp-pager button:disabled { opacity: .35; cursor: default; }
.mp-count { display: none; text-align: center; font-size: 11px; color: var(--muted); margin-top: 6px; }
@media (max-width: 620px) {
  .mp-list { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .mp-card { flex: 0 0 64vw !important; width: 64vw !important; max-width: 64vw; min-width: 0; scroll-snap-align: start; }
  .mp-card .mp-body { min-width: 0; overflow: hidden; }
  .mp-pager { display: none; }
  .mp-count { display: block; }
}


/* ==========================================================================
 * 2026-11-14 修正
 * ① 長語言文字（ja/en）的 badges 會撐出卡片
 * ② mini 卡片 grid 設 min-height 時，最後一頁不足會被拉高
 * ========================================================================== */
.card-main { min-width: 0; }
.card-right { min-width: 0; }
.badges { max-width: 100%; }
.badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; text-align: right; }
.mp-list { align-content: start; }

/* ==========================================================================
 * 2026-11-29 排行頁：每週評論 / 今週の注目 / noscript 分頁
 * ========================================================================== */
.rc-block { margin: 18px 0 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); }
.rc-h { font-size: 15px; margin: 0 0 8px; }
.rc-lead { margin: 0; font-size: 13.5px; line-height: 1.75; }
.rc-pick-h { font-size: 14px; margin: 14px 0 8px; }
.rc-picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rc-card { display: flex; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg3); text-decoration: none; color: var(--fg); }
.rc-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }
.rc-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rc-name { font-size: 12.5px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rc-meta { font-size: 11px; color: var(--muted); }
.rc-meta b { color: var(--accent); }
.rank-intro { margin: 22px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.rank-intro h2 { font-size: 15px; margin: 0 0 6px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 16px 0 8px; }
.pager-pos { font-size: 12px; color: var(--muted); }
@media (max-width: 620px) { .rc-picks { grid-template-columns: 1fr; } }

/* 2026-11-29：首頁榜單一句說明、tags 站內排行連結 */
.section-desc { margin: -4px 0 10px; font-size: 12.5px; }
.tag-rank-link { margin-left: 8px; font-size: 11px; color: var(--accent); white-space: nowrap; }

/* ==========================================================================
 * 2026-12-03：友站卡片 banner 固定 356×121
 * 問題：只固定 img 寬 300，容器高度隨圖片自然尺寸變動（對方沒給 300×96 時卡片高度不一）
 * ========================================================================== */
.friends-card-banner {
  width: 356px;
  max-width: 100%;
  height: 121px;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.friends-card-banner img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;   /* 不裁切、不放大；比例不符時留白但仍佔滿 121px 容器 */
}

/* ==========================================================================
 * 2026-12-04：`/tags` 每列 sparkline ＋「好評」主連結 ＋ hover 三榜選單
 * --------------------------------------------------------------------------
 * ❗ 外層清單仍是 `.tag-rank`（`<ul>`），所以連結的盒子改用 `.tag-rank-box`，
 *   避免與既有的 `.tag-rank { list-style:none }` 衝突。
 * ❗ 顏色沿用既有變數（上升 --good／下降 --hot／持平 --muted），不新增色票。
 * ========================================================================== */
.tag-row .spark {
  display: inline-block;
  width: 96px; height: 24px;          /* 佔位與畫完同尺寸 ⇒ 不會 CLS */
  margin-left: 10px;
  vertical-align: middle;
  align-self: center;                 /* flex 的 baseline 會把 inline-block 推高 */
  flex: 0 0 auto;
}
.spark-svg { display: block; width: 100%; height: 100%; }
.spark-svg path { stroke: var(--muted); stroke-width: 1.5; }
.spark-svg circle { fill: var(--muted); }
.spark-svg.spark-up path { stroke: var(--good); }
.spark-svg.spark-up circle { fill: var(--good); }
.spark-svg.spark-down path { stroke: var(--hot); }
.spark-svg.spark-down circle { fill: var(--hot); }
.spark-na, .spark-zero {
  display: inline-block;
  width: 96px;                        /* 與 spark 同寬，文字不會把列擠歪 */
  margin-left: 10px;
  align-self: center;
  font-size: 11px; color: var(--muted);
  text-align: center; white-space: nowrap;
}
.tag-row .delta {
  margin-left: 6px;
  min-width: 52px; text-align: right;   /* 2026-12-05：固定寬度，避免連結被推歪 */
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--muted); white-space: nowrap;
}
.tag-row .delta.up { color: var(--good); }
.tag-row .delta.down { color: var(--hot); }

.tag-rank-box { position: relative; display: inline-block; }
.rank-menu {
  position: absolute; top: 100%; left: 0;
  min-width: 96px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  padding: 4px 0;
  z-index: 20;                        /* 要高於 .meter */
  animation: rank-menu-in .12s ease-out;
}
.rank-menu--right { left: auto; right: 0; }
.rank-menu a { display: block; padding: 6px 12px; white-space: nowrap; font-size: 12px; }
.rank-menu a:hover, .rank-menu a:focus { background: var(--bg3); text-decoration: none; }
@keyframes rank-menu-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .rank-menu { animation: none; } }

/* 加 sparkline 後橫向空間變緊：平板以下提早換行（列高以內容為準，不裁切） */
@media (max-width: 899px) {
  .tag-row .in { flex-wrap: wrap; gap: 6px 10px; }
  .tag-row .spark, .spark-na, .spark-zero { margin-left: 0; }
}
@media (max-width: 620px) {
  .tag-row .spark { width: 72px; height: 20px; }
  .spark-na, .spark-zero { width: 72px; }
  .tag-row .sales { min-width: 84px; font-size: 12px; }
  .tag-row .delta { min-width: 44px; }
}
