/* ==========================================================================
   樣式
   --------------------------------------------------------------------------
   卡片規格（使用者 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;
  --good: #2f6feb;
  --hot: #b3261e;
  --hidden: #a35a00;
  --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; }
.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;
}
.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); }

/* ------------------------------ 頁面標題區 ------------------------------ */
.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); }
.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;
}
.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);
}

.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); }
.site-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 9px; border-radius: 5px;
  font-size: 12px; font-weight: 700; color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  pointer-events: none;
}

/* 中欄 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: #6b7280; }
.badge-top { background: #3d2f12; color: #ffc247; }

/* 試聽 */
.card-embeds { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.embed-stage { position: relative; }
.embed-stage iframe, .card-embeds iframe { border: 0; border-radius: 8px; display: none; }
.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; }
.section-head .gen { font-size: 11px; color: var(--muted); }
.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;
}
.mini img { width: 64px; height: 64px; object-fit: contain; 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); }

/* 標籤熱度 */
.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; }

/* ------------------------------ 年齡閘門 ------------------------------ */
body.gated > *:not(.age-gate) { filter: blur(6px); pointer-events: none; user-select: none; }
.age-gate {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 11, 13, .86);
  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(--good); border-color: var(--good); 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; }
  .mini-list { grid-template-columns: 1fr 1fr; }
}

/* ------------------------------ 標籤 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);
}
.ac-item {
  display: flex; gap: 12px; align-items: baseline;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.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 列（已套用條件 + 標籤輸入）------------------------------ */
.chips-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 0 0 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.chip-k { color: var(--muted); font-size: 11px; margin-right: 4px; }
.chip-op {
  color: var(--accent); font-weight: 700; border-color: var(--accent);
}
.tag-input-wrap { position: relative; display: inline-flex; margin-left: auto; }
.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: #1f6feb;
  --hot: #c0392b;
  --hidden: #9a5b00;
  --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, .88); }
[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;
}

/* 第二行：色點 + 分類名 + 近 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 {
  color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums;
  opacity: .85;
}

/* 下方細長條：外層是軌道，.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);
}
