/* gimy2026 — main.css
 * Vanilla CSS with CSS variables for light/dark.
 * Critical CSS subset is inlined in public/head.html (must stay in sync). */

/* ─── Tokens ────────────────────────────────────────────── */
:root {
  --bg: #FFFFFF;
  --bg-elev: #F9F9F9;
  --surface: #F2F2F2;
  --surface-hover: #E5E5E5;
  --border: #E5E5E5;
  --fg: #0F0F0F;
  --fg-secondary: #606060;
  --fg-tertiary: #909090;
  --accent: #FF0000;
  --accent-hover: #CC0000;
  --link: #065FD4;
  --overlay: rgba(0, 0, 0, 0.5);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;

  --font-sans: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;

  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  --header-h: 56px;
  --sidebar-w: 240px;
  --sidebar-mini-w: 72px;

  --t-fast: 100ms;
  --t-base: 200ms;
  --t-slow: 300ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}
@media (max-width: 640px) {
  :root { --header-h: 48px; }
}

[data-theme="dark"] {
  --bg: #0F0F0F;
  --bg-elev: #181818;
  --surface: #272727;
  --surface-hover: #383838;
  --border: #303030;
  --fg: #FFFFFF;
  --fg-secondary: #AAAAAA;
  --fg-tertiary: #717171;
  --accent: #FF0000;
  --accent-hover: #FF4444;
  --link: #3EA6FF;
  --overlay: rgba(0, 0, 0, 0.7);
}

/* ─── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.4;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--link); }
img { display: block; max-width: 100%; height: auto; }
img.is-fading { opacity: 0; }
img.is-fading.is-loaded { opacity: 1; transition: opacity 320ms ease; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
input { font-family: inherit; }

/* ─── Header ────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  z-index: 100;
  will-change: transform, backdrop-filter;
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
/* 手機版 scroll 隱藏/顯示 (僅在手機觸發,桌面不變) */
@media (max-width: 640px) {
  body.header-hidden .header { transform: translateY(-100%); }
  body.header-hidden .chips { transform: translateY(calc(var(--header-h) * -1)); }
  .chips { transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1); }
}
[data-theme="dark"] .header {
  background: rgba(15, 15, 15, 0.85);
}
.header__left { display: flex; align-items: center; gap: var(--space-3); }
.header__center { flex: 1; display: flex; justify-content: center; }
.header__right { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  transition: background var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--fg); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn--search-mobile,
.icon-btn--search-close { display: none; }
@media (max-width: 640px) {
  .icon-btn--search-mobile { display: inline-flex; }
  /* 搜尋展開模式: 隱藏其他元素, search 佔滿 header */
  body.search-open .header__left .logo,
  body.search-open [data-sidebar-toggle],
  body.search-open .header__right,
  body.search-open .icon-btn--search-mobile { display: none; }
  body.search-open .icon-btn--search-close { display: inline-flex; }
  body.search-open .header__center {
    display: flex;
    flex: 1;
  }
  body.search-open .search { max-width: none; }
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--fg);
  padding: var(--space-2) var(--space-1);
  letter-spacing: -0.5px;
}
.logo:hover { color: var(--fg); }
.logo__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  background: var(--accent);
  border-radius: 6px;
  color: #FFF;
}
.logo__mark svg { width: 12px; height: 12px; fill: currentColor; }

.search {
  display: flex;
  width: 100%;
  max-width: 640px;
}
@media (max-width: 640px) {
  .header__center { display: none; }
}
.search__input {
  flex: 1;
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
  color: var(--fg);
  font-size: var(--text-md);
  outline: none;
}
.search__input:focus { border-color: var(--link); background: var(--bg); }
.search__submit {
  width: 64px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  cursor: pointer;
}
.search__submit:hover { background: var(--surface-hover); }
.search__submit svg { width: 22px; height: 22px; fill: currentColor; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  padding: 10px 0 var(--space-3);
  background: var(--bg);
  overflow-y: auto;
  transition: width var(--t-base) var(--ease);
  z-index: 90;
}
.sidebar__group { padding: var(--space-2) var(--space-3); }
.sidebar__group:first-child { padding-top: 0; }
.sidebar__group + .sidebar__group { border-top: 1px solid var(--border); margin-top: var(--space-2); padding-top: var(--space-3); }
.sidebar__label {
  font-size: var(--text-md);
  font-weight: 500;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  color: var(--fg);
}
.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar__item:hover { background: var(--surface-hover); color: var(--fg); }
.sidebar__item.active { background: var(--surface); font-weight: 500; }
.sidebar__item svg { flex-shrink: 0; width: 24px; height: 24px; fill: currentColor; }
.sidebar__item-icon { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--surface); }
.sidebar__item--toggle {
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.sidebar__item-chevron { margin-left: auto; width: 16px !important; height: 16px !important; opacity: 0.6; }

/* Back-to-top 懸浮按鈕 */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease), background 100ms var(--ease);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.back-to-top:hover { background: var(--surface-hover); }
.back-to-top svg { width: 24px; height: 24px; fill: currentColor; }
body.show-back-top .back-to-top {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
@media (max-width: 640px) {
  .back-to-top { bottom: 16px; right: 16px; }
}

/* Sidebar mini mode */
body.sidebar-mini .sidebar { width: var(--sidebar-mini-w); }
body.sidebar-mini .sidebar__item {
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  text-align: center;
}
body.sidebar-mini .sidebar__label,
body.sidebar-mini .sidebar__group + .sidebar__group .sidebar__item { display: none; }

/* Sidebar mobile */
.sidebar__backdrop { display: none; }
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar__backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: var(--overlay);
    z-index: 80;
  }
  body.sidebar-mini .sidebar { width: var(--sidebar-w); }
}

/* ─── Main ────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 0 var(--space-5) var(--space-5);
  min-height: calc(100vh - var(--header-h));
  transition: margin-left var(--t-base) var(--ease);
}
body.sidebar-mini .main { margin-left: var(--sidebar-mini-w); }
@media (max-width: 768px) {
  .main { margin-left: 0; padding: var(--space-3); }
  body.sidebar-mini .main { margin-left: 0; }
}

/* ─── Chips (sticky 固定在 header 下方,YT 風) ────────────────────────────────── */
.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  margin: 0 calc(var(--space-5) * -1) var(--space-4);
  padding: var(--space-3) var(--space-5);
  scroll-behavior: smooth;
  /* sticky 元素加 transform 會破壞 sticky 位置運算,只用 will-change 提示 GPU */
  will-change: backdrop-filter;
  contain: layout paint;
}
.chips::-webkit-scrollbar { display: none; }
.chips { cursor: grab; user-select: none; }
.chips.is-dragging { cursor: grabbing; scroll-behavior: auto; }
[data-theme="dark"] .chips { background: rgba(15, 15, 15, 0.85); }
@media (max-width: 768px) {
  .chips {
    margin: 0 calc(var(--space-3) * -1) var(--space-3);
    padding: var(--space-2) var(--space-3);
  }
}
.chip {
  flex-shrink: 0;
  padding: 6px var(--space-3);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease);
}
.chip:hover { background: var(--surface-hover); color: var(--fg); }
.chip.active { background: var(--fg); color: var(--bg); }

/* ─── Grid + Card ────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6) var(--space-3);
}
@media (min-width: 641px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-7) var(--space-4); }
}
@media (min-width: 2560px) {
  .grid { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: var(--space-7) var(--space-4); }
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  isolation: isolate;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.05);
  z-index: -1;
  opacity: 0;
  transition: inset 250ms cubic-bezier(0.05, 0, 0, 1), opacity 250ms cubic-bezier(0.05, 0, 0, 1);
  pointer-events: none;
}
[data-theme="dark"] .card::before { background: rgba(255, 255, 255, 0.08); }
.card--c1::before { background: hsla(0,   70%, 55%, 0.18); }
.card--c2::before { background: hsla(35,  75%, 55%, 0.18); }
.card--c3::before { background: hsla(60,  70%, 50%, 0.18); }
.card--c4::before { background: hsla(140, 55%, 50%, 0.18); }
.card--c5::before { background: hsla(200, 70%, 55%, 0.18); }
.card--c6::before { background: hsla(260, 60%, 60%, 0.18); }
.card--c7::before { background: hsla(320, 65%, 60%, 0.18); }
.card:hover::before { inset: -12px -8px; opacity: 1; }
.card__thumb {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow) var(--ease);
}
.card:hover .card__thumb img { transform: scale(1.04); }
.card__badge {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  padding: 2px var(--space-2);
  background: rgba(0, 0, 0, 0.75);
  color: #FFF;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}
.card__body { display: block; min-width: 0; }
.card__title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__meta {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--fg-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .card__meta { display: none; }
}

/* ─── Section heading ────────────────────────────────────────────── */
.section { margin-bottom: var(--space-7); }
.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.section__title { font-size: var(--text-lg); font-weight: 600; }
.section__more { font-size: var(--text-sm); color: var(--fg-secondary); }
.section__more:hover { color: var(--link); }
.section__nav { display: flex; gap: var(--space-1); }

/* 橫向 carousel (YT Shorts 風) */
.section--scroll { position: relative; }
.section--scroll .grid {
  display: flex;
  grid-template-columns: none;
  gap: var(--space-3);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-2);
  cursor: grab;
  user-select: none;
}
.section--scroll .grid.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
  scroll-snap-type: none;
}
.section--scroll .grid::-webkit-scrollbar { display: none; }
.section--scroll .grid > .card {
  flex: 0 0 180px;
  width: 180px;
  min-width: 0;
  max-width: 180px;
  scroll-snap-align: start;
}
@media (max-width: 640px) {
  .section--scroll .grid > .card {
    flex: 0 0 130px;
    width: 130px;
    max-width: 130px;
  }
}

/* ─── Breadcrumb ────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
}
.breadcrumb a { color: var(--fg); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb__sep { color: var(--fg-tertiary); }
@media (max-width: 640px) { .breadcrumb { display: none; } }

/* ─── Pagination ────────────────────────────────────────────── */
.pager {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  margin: var(--space-6) 0;
  flex-wrap: wrap;
}
.pager a, .pager span {
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.pager a:hover { background: var(--surface-hover); color: var(--fg); }
.pager .current, .pager span.active { background: var(--fg); color: var(--bg); }

/* ─── Detail page (playlist 風) ────────────────────────────────────────────── */
.detail-container {
  max-width: 1280px;
  margin: 0 auto;
}
.detail-hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
@media (max-width: 640px) {
  .detail-hero {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding: var(--space-5) 0 var(--space-4);
    margin-left: calc(var(--space-3) * -1);
    margin-right: calc(var(--space-3) * -1);
    margin-bottom: var(--space-4);
    text-align: center;
    position: relative;
    isolation: isolate;
    overflow: hidden;
  }
  .detail-hero::before {
    content: "";
    position: absolute;
    inset: -10%;
    z-index: -2;
    background-image: var(--cover-blur);
    background-size: cover;
    background-position: center;
    filter: blur(40px) saturate(150%);
    opacity: 0.45;
    transform: scale(1.15);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 75%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 75%, transparent);
  }
  /* 邊界模糊漸層淡出 */
  .detail-hero::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 50%;
    background: linear-gradient(to bottom, transparent, var(--bg) 92%);
    z-index: -1;
    pointer-events: none;
  }
  .detail-cover {
    margin: 0 auto;
    width: 45%;
    max-width: 240px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  }
  .detail-info {
    padding: 0 var(--space-4);
    text-align: left;
  }
  .detail-info h1 { text-align: center; font-size: var(--text-2xl); margin-bottom: 0; }
  .detail-tags {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: 10px;
    margin-bottom: 0;
  }
  .detail-tag {
    padding: 4px var(--space-3);
    background: var(--surface);
    color: var(--fg);
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
  }
  .detail-sub { text-align: left; }
  .detail-meta { text-align: left; line-height: 1; }
  .detail-meta strong { font-weight: 600; color: var(--fg); margin-right: 2px; }
  .detail-meta a { color: var(--fg); }
  .detail-meta a:hover { text-decoration: underline; }
  /* 手機版 detail-info 用 flex,actions 透過 order 上移到 meta 之前 */
  .detail-info { display: flex; flex-direction: column; }
  .detail-info h1 { order: 1; }
  .detail-tags { order: 2; }
  .detail-actions { order: 3; justify-content: center; margin-bottom: var(--space-5); }
  .detail-meta { order: 4; }
}
.detail-cover {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info h1 {
  font-size: var(--text-3xl);
  line-height: 1.2;
  margin-bottom: var(--space-2);
}
@media (max-width: 640px) { .detail-info h1 { font-size: var(--text-xl); } }
.detail-sub {
  font-size: var(--text-md);
  color: var(--fg-secondary);
  margin-bottom: var(--space-3);
}
.detail-meta { font-size: 14px; color: var(--fg-secondary); margin-bottom: var(--space-2); line-height: 1.5; }
.detail-meta a { color: var(--fg); }
.detail-meta a:hover { text-decoration: underline; }
@media (max-width: 640px) { .detail-meta { line-height: 1; } }
.detail-actions { margin-top: var(--space-4); display: flex; gap: var(--space-2); flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-pill);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease);
}
.btn--primary { background: var(--fg); color: var(--bg); }
.btn--primary:hover { background: var(--fg); color: var(--bg); opacity: 0.85; }
.btn--ghost { background: var(--surface); color: var(--fg); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--fg); }

.desc-block {
  margin-bottom: var(--space-6);
  font-size: var(--text-base);
  line-height: 2;
  color: var(--fg);
}
.desc-block h2 { font-size: var(--text-lg); margin-bottom: var(--space-2); }

.playlist-block { margin-bottom: var(--space-6); }
.playlist-block__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
.playlist-block__title { font-size: var(--text-lg); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.player-icon {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  color: #FFF;
  letter-spacing: 0.5px;
}
.player-icon--qiyi { background: #00BB57; }
.player-icon--qq { background: #1F8FE5; }
.player-icon--youku { background: #006EFF; }
.player-icon--mgtv { background: #FF6633; }
.player-icon--bilibili { background: #FB7299; }
.player-icon--hd { background: #FF4B5B; }
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--space-2);
}
.playlist-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 var(--space-2);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease);
}
.playlist-grid a:hover { background: var(--surface-hover); color: var(--fg); }
.playlist-grid a.active { background: var(--accent); color: #FFF; }

/* ─── Play page (watch 風) ────────────────────────────────────────────── */
.watch {
  display: grid;
  grid-template-columns: 1fr 402px;
  gap: var(--space-6);
  align-items: start;
}
.watch-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.watch-side { min-width: 0; }
@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; gap: 0; }
}
.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.player-frame :is(iframe, video, embed, object) { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-frame .MacPlayer { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; }

.watch-title { font-size: var(--text-xl); line-height: 1.3; margin-bottom: var(--space-2); }
.watch-title a { color: var(--fg); }
.watch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--space-5);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  margin: 0;
}
.watch-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.watch-meta > span + span::before {
  content: "";
  position: absolute;
  left: calc(var(--space-5) * -0.5);
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 12px;
  background: var(--border);
}
.watch-meta strong { font-weight: 600; color: var(--fg); }
.watch-meta a { color: var(--fg); }
.watch-meta a:hover { text-decoration: underline; }

/* meta + 按鈕 同列 (左右對齊,YT 風) */
.watch-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

/* Player tools row (上下集 + 劇院模式) */
.player-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: 0;
}
.player-tools .updown { display: flex; gap: var(--space-2); margin: 0; }
/* 手機版按鈕一排,超出可橫向滑動 */
@media (max-width: 640px) {
  .player-tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .player-tools::-webkit-scrollbar { display: none; }
  .player-tools > *, .player-tools .updown > * { flex-shrink: 0; }
  .player-tools .pill-btn, .player-tools .updown a {
    padding: var(--space-2) var(--space-3);
    font-size: 12px;
  }
}

.updown {
  display: flex;
  gap: var(--space-2);
}
.updown a, .pill-btn {
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 0;
  cursor: pointer;
}
.updown a:hover, .pill-btn:hover { background: var(--surface-hover); color: var(--fg); }
.pill-btn svg { width: 18px; height: 18px; fill: currentColor; }
.pill-btn.active { background: var(--fg); color: var(--bg); }
@media (max-width: 640px) { [data-theater-toggle] { display: none; } }

/* Route chips (頂部橫向滾動 + YT 風 inline 箭頭) */
.route-chips-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.route-chips {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-2) 0;
  scroll-behavior: smooth;
}
.route-chips::-webkit-scrollbar { display: none; }
.route-chips { cursor: grab; user-select: none; }
.route-chips.is-dragging { cursor: grabbing; scroll-behavior: auto; }
.route-chip {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  white-space: nowrap;
  font-weight: 500;
}
.route-chip:hover { background: var(--surface-hover); color: var(--fg); }
.route-chip.active { background: var(--fg); color: var(--bg); }

/* 左右箭頭按鈕 (inline,只在 overflow 時顯示) */
.chip-nav {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--fg);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background var(--t-fast) var(--ease);
}
.chip-nav:hover { background: var(--surface-hover); }
.chip-nav svg { width: 20px; height: 20px; fill: currentColor; }
/* route-chips 用 has-prev/has-next 顯示控制 */
.route-chips-wrap .chip-nav { display: none; }
.route-chips-wrap.has-prev .chip-nav--prev { display: flex; }
.route-chips-wrap.has-next .chip-nav--next { display: flex; }

.watch-side .watch-side-block { margin-bottom: var(--space-5); }
.watch-side h2 { font-size: var(--text-md); margin-bottom: var(--space-3); }

/* Episodes 3 欄網格 */
.episodes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  max-height: calc(var(--player-h, 480px) * 2 / 3);
  overflow-y: auto;
}
/* 手機版 sidebar 在 player 下方,不需要限制 2/3 player 高,改給更大空間 */
@media (max-width: 1100px) {
  .episodes-grid { max-height: 50vh; }
}
.episodes-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 var(--space-2);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.episodes-grid a:hover { background: var(--surface-hover); color: var(--fg); }
.episodes-grid a.active { background: var(--accent); color: #FFF; }
.episodes-route { display: none; }
.episodes-route.active { display: block; }

/* 劇院模式: player 橫跨整列,sidebar 保留在右側,player 上下黑底(YT 風)
 * 透過 .watch-left { display: contents } 把 player / main 拆出來變 grid 子項,
 * 再用 grid-template-areas 重排。 */
.watch.theater .watch-left { display: contents; }
.watch.theater {
  grid-template-areas:
    "player player"
    "main   side";
}
.watch.theater .watch-player { grid-area: player; }
.watch.theater .watch-main { grid-area: main; }
.watch.theater .watch-side { grid-area: side; }
.watch.theater .watch-player {
  background: #0F0F0F;
  margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) 0;
  padding: var(--space-4) var(--space-5);
}
/* 劇院模式時隱藏麵包屑 (更乾淨,專注播放) */
.main:has(.watch.theater) .breadcrumb { display: none; }
.watch.theater .player-frame {
  border-radius: var(--radius-md);
  max-width: 1600px;
  max-height: calc(100vh - var(--header-h) - 80px);
  margin: 0 auto;
}
@media (max-width: 1100px) {
  .watch.theater { grid-template-areas: "player" "main" "side"; }
  .watch.theater .watch-player {
    margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) 0;
    padding: var(--space-3);
  }
}

.recommend-list { display: flex; flex-direction: column; gap: var(--space-1); }
.recommend-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background var(--t-fast) var(--ease);
}
.recommend-item:hover { background: rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .recommend-item:hover { background: rgba(255, 255, 255, 0.1); }
.recommend-item__thumb {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.recommend-item__thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow) var(--ease); }
.recommend-item:hover .recommend-item__thumb img { transform: scale(1.04); }
.recommend-item__body { padding: 0; min-width: 0; }
.recommend-item__title {
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.35;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--space-2);
}
.recommend-item:hover .recommend-item__title { color: var(--link); }
.recommend-item__meta {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Search results (直立列表) ────────────────────────────────────────────── */
.search-list { display: flex; flex-direction: column; gap: var(--space-5); }
.search-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-4);
}
@media (max-width: 640px) {
  .search-item { grid-template-columns: 120px 1fr; gap: var(--space-3); }
}
.search-item__thumb { aspect-ratio: 2 / 3; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.search-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-item__title { font-size: var(--text-lg); line-height: 1.3; color: var(--fg); margin-bottom: var(--space-2); }
.search-item__title:hover { color: var(--link); }
.search-item__meta { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: var(--space-2); }
.search-item__desc { font-size: var(--text-sm); color: var(--fg-secondary); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.search-summary { font-size: var(--text-md); margin-bottom: var(--space-5); color: var(--fg-secondary); }
.search-summary strong { color: var(--fg); }

/* ─── Trending / Top ────────────────────────────────────────────── */
/* 排行榜:多欄自動排版 */
.top-cols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-6) var(--space-5);
}
@media (max-width: 640px) {
  .top-cols { grid-template-columns: 1fr; gap: var(--space-6); }
}
.top-col__title {
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--border);
}
.top-list { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.top-item {
  display: grid;
  grid-template-columns: 32px 70px 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) 0;
}
.top-item__rank {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg-tertiary);
  text-align: center;
  font-style: italic;
  line-height: 1;
}
.top-item:nth-child(1) .top-item__rank { color: #FF5252; }
.top-item:nth-child(2) .top-item__rank { color: #4CAF50; }
.top-item:nth-child(3) .top-item__rank { color: #FF80AB; }
.top-item__thumb { aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--surface); }
.top-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.top-item__info { min-width: 0; }
.top-item__title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--fg);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-item__title:hover { color: var(--link); }
.top-item__status { font-size: 12px; color: var(--fg-secondary); margin: 2px 0; }
.top-item__cast { font-size: 12px; color: var(--fg-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.top-item__heat { text-align: right; min-width: 0; }
.top-item__heat-num { font-size: 14px; font-weight: 600; color: var(--fg); display: inline-flex; align-items: center; gap: 4px; }
.top-item__heat-num svg { width: 14px; height: 14px; fill: var(--fg-secondary); }
.top-item__heat-label { font-size: 11px; color: var(--fg-tertiary); display: block; margin-top: 2px; }

/* ─── Filter bar (type / show 上方完整篩選卡片) ────────────────────────── */
.filter-bar {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}
.filter-bar__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.filter-bar__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.filter-bar__title .sub { font-size: var(--text-sm); color: var(--fg-secondary); font-weight: 400; }
.filter-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.filter-row + .filter-row { border-top: 1px dashed var(--border); }
.filter-label {
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  min-width: 44px;
  flex-shrink: 0;
  padding: 6px 0;
}
.filter-options {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
  cursor: grab;
  user-select: none;
}
.filter-options::-webkit-scrollbar { display: none; }
.filter-options.is-dragging { cursor: grabbing; scroll-behavior: auto; }
.filter-options a {
  flex-shrink: 0;
  padding: 4px var(--space-3);
  font-size: var(--text-sm);
  color: var(--fg);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.filter-options a:hover { background: var(--surface-hover); color: var(--fg); }
.filter-options a.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ─── Footer ────────────────────────────────────────────── */
.footer {
  margin-left: var(--sidebar-w);
  padding: var(--space-5);
  border-top: 1px solid var(--border);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  text-align: center;
  transition: margin-left var(--t-base) var(--ease);
}
body.sidebar-mini .footer { margin-left: var(--sidebar-mini-w); }
@media (max-width: 768px) { .footer { margin-left: 0; } }
.footer a { color: var(--fg-secondary); margin: 0 var(--space-2); }
.footer a:hover { color: var(--link); }

/* ─── Empty state ────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--space-8) var(--space-3); color: var(--fg-secondary); }
