/* ==========================================================================
   Bangumi 私人动画库 — 离线优先的收藏界面
   ========================================================================== */

:root {
  --pink: #f09199;
  --pink-deep: #dc6f7a;
  --pink-ink: #b34e59;
  --pink-soft: #fdeef0;
  --pink-wash: #fff7f8;

  --ink: #25242a;
  --ink-2: #45444e;
  /* 正文对比度：--muted ≈ 5.6:1、--faint ≈ 4.6:1（对 --paper），保持 muted 比 faint 深一档。 */
  --muted: #63616b;
  --faint: #706e78;
  --paper: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --line: rgba(37, 36, 42, 0.09);
  --line-strong: rgba(37, 36, 42, 0.16);

  --green: #5c9a78;
  --amber: #c38a3d;

  --shadow-xs: 0 1px 2px rgba(33, 27, 29, 0.04);
  --shadow-sm: 0 4px 14px rgba(45, 33, 36, 0.06);
  --shadow-md: 0 12px 32px rgba(45, 33, 36, 0.1);
  --shadow-lg: 0 28px 80px rgba(35, 25, 28, 0.18);

  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --font-sans: "MiSans", "HarmonyOS Sans SC", "PingFang SC", "Noto Sans SC",
    "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC",
    Georgia, serif;
  --font-number: "DIN Alternate", "Bahnschrift", "Avenir Next", "Segoe UI", sans-serif;

  --topbar-base-h: 68px;
  --topbar-h: var(--topbar-base-h);
  --sidebar-w: 238px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  background:
    radial-gradient(1100px 520px at 88% -12%, rgba(250, 196, 203, 0.4), transparent 62%),
    radial-gradient(900px 480px at -8% 24%, rgba(233, 224, 211, 0.55), transparent 58%),
    var(--paper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

::selection {
  background: rgba(240, 145, 153, 0.32);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(70, 64, 68, 0.18);
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(70, 64, 68, 0.3);
  border: 3px solid transparent;
  background-clip: content-box;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--pink-deep);
  outline-offset: 2px;
}

/* ==========================================================================
   顶栏
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar-base-h);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 30px;
  background: rgba(249, 247, 244, 0.8);
  border-bottom: 1px solid rgba(37, 36, 42, 0.07);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--ink-2);
  transition: background 0.18s var(--ease);
}
.icon-btn:hover {
  background: rgba(37, 36, 42, 0.06);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* 桌面隐藏菜单按钮，窄屏布局会重新显示。 */
.menu-btn {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-radius: 11px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  padding-bottom: 2px;
  background: linear-gradient(145deg, #f7acb2 0%, #ef8c95 48%, #df6c78 100%);
  box-shadow:
    0 5px 14px rgba(224, 108, 120, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.01em;
  font-weight: 750;
}
.brand-text span {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.16em;
  margin-top: 3px;
}

.search-box {
  flex: 1 1 auto;
  /* flex item 默认 min-width:auto；不归零会让搜索框拒绝收缩，把右侧按钮挤出视口。 */
  min-width: 0;
  max-width: 620px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 13px;
  border: 1px solid rgba(37, 36, 42, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    background 0.2s var(--ease);
}
.search-box:focus-within {
  border-color: rgba(224, 108, 120, 0.48);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(240, 145, 153, 0.12);
}
.search-icon {
  width: 17px;
  height: 17px;
  color: var(--faint);
  flex-shrink: 0;
}
.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}
.search-box input::placeholder {
  color: #a3a1aa;
}
.search-box input::-webkit-search-cancel-button {
  display: none;
}
.search-box kbd {
  font-family: var(--font-number);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-bottom-color: rgba(37, 36, 42, 0.16);
  background: #faf9f7;
  border-radius: 5px;
  padding: 1px 6px;
  line-height: 1.5;
}
.search-clear {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}
.search-clear:hover {
  background: rgba(37, 36, 42, 0.06);
  color: var(--ink);
}
.search-clear svg {
  width: 13px;
  height: 13px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.btn {
  height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition:
    transform 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    background 0.16s var(--ease),
    border-color 0.16s var(--ease);
}
.btn svg {
  width: 15px;
  height: 15px;
}
.btn:hover {
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #f39aa2, #e57681);
  box-shadow: 0 6px 18px rgba(224, 108, 120, 0.28);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #f5a3aa, #e06d79);
  box-shadow: 0 9px 24px rgba(224, 108, 120, 0.34);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
}
.btn.danger {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #d96a72, #c94f5b);
  box-shadow: 0 6px 18px rgba(190, 69, 80, 0.25);
}
.btn.small {
  height: 31px;
  padding: 0 11px;
  font-size: 11.5px;
  border-radius: 8px;
}
.btn:disabled {
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

/* ==========================================================================
   布局与侧栏
   ========================================================================== */

.layout {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 30px 16px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 27px;
}

.sidebar-mobile-head {
  display: none;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sidebar-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.sidebar-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.nav-item {
  width: 100%;
  height: 37px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  text-align: left;
  transition:
    background 0.16s var(--ease),
    color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}
.nav-item svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  stroke-width: 1.65;
  flex-shrink: 0;
  transition: color 0.16s var(--ease);
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}
.nav-item.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 16px rgba(45, 33, 36, 0.07);
  font-weight: 650;
}
.nav-item.active svg {
  color: var(--pink-deep);
}
.nav-count {
  margin-left: auto;
  min-width: 21px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(37, 36, 42, 0.055);
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.55;
}
.nav-item.active .nav-count {
  background: var(--pink-soft);
  color: var(--pink-ink);
}

.tag-chip {
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    color 0.16s var(--ease),
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease);
}
.tag-chip:hover {
  color: var(--pink-ink);
  border-color: rgba(224, 108, 120, 0.3);
  background: #fff;
}
.sidebar-favorites .favorite-stats {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  padding-left: 4px;
}
.favorite-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 26px;
  padding: 0 9px 0 13px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 10.5px;
  transition:
    color 0.15s var(--ease),
    background-color 0.15s var(--ease);
}
.favorite-stat::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-right: auto;
  margin-left: -7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}
.favorite-stat strong {
  color: var(--ink-2);
  font-family: var(--font-number);
  font-size: 10.5px;
  font-weight: 650;
}
.favorite-stat:hover,
.favorite-stat.active {
  background: var(--pink-wash);
  color: var(--pink-ink);
}
.favorite-stat.watching::before { background: #5d89cb; }
.favorite-stat.watched::before { background: #5c9a78; }
.favorite-stat.unwatched::before { background: #a7a4ad; }
.favorite-stat.active strong { color: inherit; }
.sidebar-backdrop {
  display: none;
}

/* ==========================================================================
   主区域
   ========================================================================== */

.main {
  flex: 1;
  min-width: 0;
  padding: 34px 36px 88px;
}

.page-head {
  margin-bottom: 24px;
  animation: fadeUp 0.45s var(--ease) both;
}
.page-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.page-eyebrow::before {
  content: "";
  width: 15px;
  height: 2px;
  border-radius: 2px;
  background: var(--pink);
}
.page-title-row {
  display: flex;
  align-items: baseline;
  gap: 13px;
  flex-wrap: wrap;
}
.page-title {
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.2;
}
.page-title .count {
  margin-left: 10px;
  color: var(--faint);
  font-family: var(--font-number);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  vertical-align: 3px;
}
.page-sub {
  margin-top: 7px;
  max-width: 640px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ==========================================================================
   工具栏
   ========================================================================== */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 0 17px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-label {
  color: var(--faint);
  font-size: 10.5px;
  margin-right: 1px;
}

.btn.purge-all-btn {
  color: var(--pink-ink);
  background: var(--pink-wash);
  border-color: rgba(201, 79, 91, 0.18);
}
.btn.purge-all-btn:hover {
  color: var(--pink-ink);
  background: var(--pink-soft);
  border-color: rgba(201, 79, 91, 0.3);
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 27px 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  transition:
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    color 0.16s var(--ease);
}
.select-wrap select:hover {
  background: #fff;
  border-color: var(--line-strong);
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.chip {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--pink-soft);
  color: var(--pink-ink);
  font-size: 11px;
  font-weight: 600;
  max-width: 220px;
}
.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip button {
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: inherit;
  opacity: 0.7;
}
.chip button:hover {
  background: rgba(179, 78, 89, 0.12);
  opacity: 1;
}
.chip svg {
  width: 10px;
  height: 10px;
}

.clear-filters {
  color: var(--muted);
  font-size: 10.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(136, 135, 146, 0.4);
}
.clear-filters:hover {
  color: var(--pink-ink);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: rgba(37, 36, 42, 0.055);
  gap: 2px;
}
.segmented button {
  height: 27px;
  padding: 0 10px;
  border-radius: inherit;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  transition:
    color 0.16s var(--ease),
    background-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}
.segmented button:hover {
  color: var(--ink-2);
  background: var(--line);
}
.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 7px rgba(45, 33, 36, 0.08);
}
.segmented.compact button {
  height: 24px;
  padding: 0 8px;
  font-size: 10.5px;
}
.filter-pill {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  transition:
    color 0.15s var(--ease),
    background-color 0.15s var(--ease),
    border-color 0.15s var(--ease);
}
.filter-pill svg {
  width: 12px;
  height: 12px;
}
.filter-pill:hover {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--pink-ink);
}
.filter-pill.active {
  color: var(--pink-ink);
  border-color: rgba(224, 108, 120, 0.26);
  background: var(--pink-soft);
}
.filter-pill.active svg {
  fill: currentColor;
}
.btn.subtle {
  height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 11px;
}
.btn.subtle:hover {
  color: var(--pink-ink);
  background: var(--pink-wash);
  border-color: rgba(224, 108, 120, 0.22);
  box-shadow: none;
}
.btn.subtle svg {
  width: 13px;
  height: 13px;
}

.icon-toggle-group {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.55);
}
.icon-toggle {
  width: 28px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: inherit;
  color: var(--faint);
}
.icon-toggle svg {
  width: 14px;
  height: 14px;
}
.icon-toggle:hover {
  color: var(--ink-2);
  background: var(--line);
}
.icon-toggle.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(45, 33, 36, 0.12);
}

.order-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
  transition:
    color 0.16s var(--ease),
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease);
}
.order-btn:hover {
  color: var(--ink);
  background: #fff;
}
.order-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.25s var(--ease);
}
.order-btn.asc svg {
  transform: rotate(180deg);
}

.select-mode-btn {
  height: 32px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.select-mode-btn svg {
  width: 13px;
  height: 13px;
}
.select-mode-btn:hover,
.select-mode-btn.active {
  color: var(--ink);
  background: #fff;
  border-color: var(--line-strong);
}
.select-mode-btn.active {
  color: var(--pink-ink);
  border-color: rgba(224, 108, 120, 0.35);
  background: var(--pink-wash);
}

/* ==========================================================================
   卡片网格
   ========================================================================== */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 28px 19px;
}
.grid.is-loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.card {
  position: relative;
  min-width: 0;
  border-radius: var(--radius);
  animation: fadeUp 0.42s var(--ease) both;
  animation-delay: min(calc(var(--i, 0) * 24ms), 360ms);
}
.card:hover {
  z-index: 2;
}

.card-media {
  position: relative;
}

.poster {
  position: relative;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  border-radius: 12px;
  background:
    linear-gradient(145deg, #eee8e3, #ded5cf);
  box-shadow:
    0 1px 2px rgba(45, 33, 36, 0.08),
    0 10px 24px rgba(45, 33, 36, 0.07);
  transition:
    transform 0.32s var(--ease),
    box-shadow 0.32s var(--ease);
  isolation: isolate;
}
.card:hover .poster {
  transform: translateY(-5px);
  box-shadow:
    0 2px 3px rgba(45, 33, 36, 0.08),
    0 20px 38px rgba(45, 33, 36, 0.16);
}
.poster img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform 0.6s var(--ease),
    filter 0.3s var(--ease);
}
.card:hover .poster img {
  transform: scale(1.035);
}
.poster.is-broken img {
  display: none;
}
.poster-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: rgba(255, 255, 255, 0.88);
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 700;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.28), transparent 40%),
    linear-gradient(145deg, #d8a6a2, #b98a8e 45%, #7c6671);
}
.poster-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    to top,
    rgba(16, 13, 15, 0.78) 0%,
    rgba(16, 13, 15, 0.2) 24%,
    transparent 46%
  );
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}
.card:hover .poster-shade,
.card:focus-within .poster-shade {
  opacity: 1;
}

.score-badge {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 8px;
  height: 24px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 7px;
  background: rgba(22, 19, 22, 0.68);
  color: #fff;
  font-family: var(--font-number);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.score-badge svg {
  width: 9px;
  height: 9px;
  fill: currentColor;
  stroke: none;
  color: #ffd47e;
}
.score-badge.score-high {
  background: rgba(131, 93, 30, 0.86);
}
.score-badge.score-mid {
  background: rgba(36, 90, 67, 0.82);
}
.score-badge.score-none {
  background: rgba(22, 19, 22, 0.38);
  color: rgba(255, 255, 255, 0.72);
}

.rank-badge {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 8px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #6f5b3c;
  font-family: var(--font-number);
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}
.rank-badge::before {
  content: "#";
  opacity: 0.5;
  font-weight: 500;
}

.card-actions {
  position: absolute;
  z-index: 4;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.22s var(--ease),
    transform 0.22s var(--ease);
  pointer-events: none;
}
.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.card-action {
  flex: 1;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 10px;
  font-weight: 650;
  backdrop-filter: blur(8px);
  transition:
    background-color 0.15s var(--ease),
    color 0.15s var(--ease),
    box-shadow 0.15s var(--ease);
}
.card-action svg {
  width: 11px;
  height: 11px;
}
.card-action:hover {
  background: #fff;
}
.card-action.remove {
  color: #b34e59;
  background: rgba(255, 246, 247, 0.94);
}
.card-action.remove:hover {
  background: #fff0f2;
}

.select-toggle {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  width: 22px;
  height: 22px;
  display: none;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  cursor: pointer;
}
.select-toggle input {
  appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1.5px solid rgba(37, 36, 42, 0.3);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.select-toggle input:checked {
  border-color: var(--pink-deep);
  background: var(--pink-deep);
  box-shadow: inset 0 0 0 2px #fff;
}
.grid.selecting .select-toggle {
  display: grid;
}

.grid.selecting .rank-badge {
  display: none;
}
.card.selected .poster {
  box-shadow:
    0 0 0 3px var(--pink),
    0 12px 28px rgba(224, 108, 120, 0.25);
}

.card-body {
  padding: 10px 2px 0;
}
.card-title {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
  text-wrap: balance;
}
.card-alt {
  margin-top: 2px;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.4em;
}
.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 10px;
}
.card-meta span {
  display: inline-flex;
  align-items: center;
}
.card-meta span + span::before {
  content: "·";
  margin-right: 5px;
  color: var(--faint);
}
.card-meta .meta-extra {
  display: none;
}
.grid.list-view .card-meta .meta-extra {
  display: inline-flex;
}
.nsfw-text {
  color: #b34e59 !important;
  font-weight: 700;
}
.card-tags {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  /* 留出 focus-visible 的 2px outline + 2px offset，避免键盘焦点被裁掉。 */
  padding: 4px 0;
  overflow: hidden;
  min-height: 26px;
}
.card-tag {
  flex-shrink: 0;
  max-width: 90px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(37, 36, 42, 0.045);
  color: var(--muted);
  font-size: 9px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card:hover .card-tag {
  background: rgba(240, 145, 153, 0.1);
  color: var(--pink-ink);
}

/* 收藏 / 观看状态（卡片内直接操作） */
.card-state {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed rgba(37, 36, 42, 0.09);
}
.state-btn {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  white-space: nowrap;
  transition:
    color 0.15s var(--ease),
    background-color 0.15s var(--ease),
    border-color 0.15s var(--ease),
    opacity 0.15s var(--ease);
}
.state-btn svg {
  width: 11px;
  height: 11px;
}
.state-btn:hover {
  color: var(--pink-ink);
  border-color: rgba(224, 108, 120, 0.24);
  background: #fff;
}
.state-btn.favorite-toggle.active {
  color: var(--pink-ink);
  border-color: rgba(224, 108, 120, 0.24);
  background: var(--pink-soft);
}
.state-btn.favorite-toggle.active svg {
  fill: currentColor;
}
.state-btn.busy {
  opacity: 0.55;
  pointer-events: none;
}
.watch-switch {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: rgba(37, 36, 42, 0.05);
}
.watch-btn {
  height: 20px;
  padding: 0 6px;
  border-radius: inherit;
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    color 0.14s var(--ease),
    background-color 0.14s var(--ease),
    box-shadow 0.14s var(--ease);
}
.watch-btn:hover {
  color: var(--ink-2);
  background: var(--line);
}
.watch-btn.active {
  background: #fff;
  color: var(--ink-2);
  box-shadow: 0 1px 4px rgba(45, 33, 36, 0.1);
}
.watch-btn.active.watching {
  color: #4d75b0;
  background: rgba(93, 137, 203, 0.12);
  box-shadow: none;
}
.watch-btn.active.watched {
  color: #4b8666;
  background: rgba(92, 154, 120, 0.13);
  box-shadow: none;
}

/* 列表视图 */
.grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.grid.list-view .card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  grid-template-areas: "poster body actions";
  align-items: center;
  gap: 15px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.58);
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}
.grid.list-view .card-media {
  display: contents;
}
.grid.list-view .card:hover {
  background: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.grid.list-view .poster {
  grid-area: poster;
  width: 72px;
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(45, 33, 36, 0.12);
}
.grid.list-view .card:hover .poster {
  transform: none;
}
.grid.list-view .card-body {
  grid-area: body;
  padding: 0;
  min-width: 0;
}
.grid.list-view .card-title {
  -webkit-line-clamp: 1;
  min-height: 0;
  font-size: 14px;
}
.grid.list-view .card-alt {
  margin-top: 3px;
}
.grid.list-view .card-meta {
  margin-top: 6px;
}
.grid.list-view .card-tags {
  display: none;
}
.grid.list-view .card-actions {
  grid-area: actions;
  justify-self: end;
  position: static;
  width: auto;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  flex-shrink: 0;
  gap: 5px;
}
.grid.list-view .card-actions .card-action {
  flex: 0 0 auto;
  padding: 0 11px;
  background: rgba(37, 36, 42, 0.045);
}
.grid.list-view .card-actions .card-action:hover {
  background: rgba(37, 36, 42, 0.08);
}
.grid.list-view .card-actions .card-action.remove {
  background: var(--pink-soft);
}
.grid.list-view .card-state {
  margin-top: 5px;
  padding-top: 0;
  border-top: 0;
}
.grid.list-view .card-tags {
  display: none;
}

.grid.list-view .score-badge {
  display: none;
}
.grid.list-view .select-toggle {
  top: 6px;
  left: 6px;
}

/* ==========================================================================
   批量操作栏
   ========================================================================== */

.bulkbar {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px 8px 16px;
  border-radius: 13px;
  background: rgba(32, 29, 33, 0.94);
  color: #fff;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  animation: bulkIn 0.3s var(--ease) both;
  white-space: nowrap;
}
.bulkbar strong {
  font-family: var(--font-number);
  font-size: 12px;
  margin-right: 2px;
}
.bulkbar .bulk-sub {
  color: rgba(255, 255, 255, 0.55);
  font-size: 10.5px;
}
.bulkbar button {
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}
.bulkbar button:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.bulkbar button.bulk-danger {
  background: #d9636e;
  color: #fff;
}
.bulkbar button.bulk-danger:hover {
  background: #e26d78;
}
.bulkbar button:disabled {
  opacity: 0.4;
}

/* ==========================================================================
   收藏夹概览
   ========================================================================== */

.favorites-summary {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(224, 108, 120, 0.16);
  border-radius: 15px;
  background:
    radial-gradient(circle at 0% 0%, rgba(240, 145, 153, 0.16), transparent 45%),
    rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-xs);
  animation: fadeUp 0.4s var(--ease) both;
}
.favorites-summary-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 200px;
}
.favorites-summary-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--pink-ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
}
.favorites-summary-eyebrow svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}
.favorites-summary-main strong {
  margin-top: 2px;
  font-family: var(--font-number);
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.favorites-summary-main > span:last-child {
  color: var(--muted);
  font-size: 10.5px;
}
.favorites-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 7px;
  flex: 1;
  max-width: 560px;
}
.favorites-summary-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  text-align: left;
  transition:
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    transform 0.16s var(--ease);
}
.favorites-summary-card:hover {
  background: #fff;
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.favorites-summary-card.active {
  border-color: rgba(224, 108, 120, 0.3);
  background: var(--pink-soft);
}
.fs-icon {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(37, 36, 42, 0.05);
  color: var(--muted);
}
.fs-icon svg {
  width: 12px;
  height: 12px;
}
.favorites-summary-card.all .fs-icon { color: var(--pink-ink); background: rgba(240, 145, 153, 0.14); }
.favorites-summary-card.all .fs-icon svg { fill: currentColor; }
.favorites-summary-card.watching .fs-icon { color: #4d75b0; background: rgba(93, 137, 203, 0.12); }
.favorites-summary-card.watched .fs-icon { color: #4b8666; background: rgba(92, 154, 120, 0.13); }
.fs-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.fs-copy strong {
  font-family: var(--font-number);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}
.fs-copy em {
  color: var(--muted);
  font-size: 9.5px;
  font-style: normal;
}

/* 详情抽屉里的本地记录 */
.drawer-personal {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.52);
}
.drawer-personal .card-state {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.drawer-personal .state-btn {
  height: 28px;
  font-size: 10.5px;
}
.drawer-personal .watch-switch {
  padding: 3px;
}
.drawer-personal .watch-btn {
  height: 22px;
  font-size: 10px;
  padding: 0 8px;
}
.personal-record-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
}
.personal-record-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}
.personal-record-form input,
.personal-record-form select {
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface, transparent);
  color: inherit;
  font: inherit;
}
.drawer-personal-help {
  margin-top: 9px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.6;
}

/* ==========================================================================
   空状态 / 分页 / 骨架屏
   ========================================================================== */

.empty {
  padding: 80px 24px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeUp 0.45s var(--ease) both;
}
.empty-art {
  width: 118px;
  height: 106px;
  position: relative;
  margin-bottom: 22px;
}
.empty-art::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(190, 94, 105, 0.3), rgba(190, 94, 105, 0.08) 48%, transparent 72%);
  filter: blur(5px);
}
.empty-art::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff 8%, #f4c2c7 52%, #dc8e97);
  box-shadow:
    0 4px 10px rgba(185, 95, 105, 0.35),
    -84px 58px 0 -2px rgba(240, 145, 153, 0.55),
    -74px 68px 0 -3px rgba(240, 145, 153, 0.28);
}
.empty-art .ring {
  position: absolute;
  inset: 8px 6px 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 31% 24%, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0) 30%),
    radial-gradient(circle at 72% 82%, rgba(240, 145, 153, 0.22), transparent 54%),
    linear-gradient(150deg, #fff 0%, #fbf3f1 42%, #ecd6d3 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 18px 32px -12px rgba(183, 83, 95, 0.42),
    0 3px 8px rgba(183, 83, 95, 0.12),
    inset 0 2px 3px rgba(255, 255, 255, 0.98),
    inset 0 -12px 20px rgba(196, 111, 120, 0.15);
  animation: emptyFloat 6s ease-in-out infinite;
}
.empty-art .ring::before {
  content: "";
  position: absolute;
  inset: -13px -9px;
  border-radius: 50%;
  border: 1px dashed rgba(216, 118, 128, 0.32);
  transform: rotate(-14deg);
}
.empty-art .ring::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 0 16px rgba(240, 145, 153, 0.12);
  pointer-events: none;
}
.empty-art svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  z-index: 2;
  color: #c88f93;
  stroke-width: 1.35;
  filter: drop-shadow(0 4px 7px rgba(164, 78, 89, 0.3));
  animation: emptyIconFloat 6s ease-in-out infinite;
}
.empty h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.empty p {
  margin-top: 7px;
  max-width: 380px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}
.empty-actions {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.pager {
  margin-top: 38px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 13px;
}
.pager button {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}
.pager button:hover:not(:disabled) {
  background: #fff;
  border-color: var(--line-strong);
}
.pager button:disabled {
  opacity: 0.35;
}
.pager-info {
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 11px;
}
.pager-info strong {
  color: var(--ink);
  font-weight: 600;
}

.skel {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(224, 217, 211, 0.45);
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(248, 245, 241, 0.85) 38%,
    transparent 56%
  );
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite linear;
  will-change: transform;
}
.skel-title {
  width: 220px;
  height: 32px;
  margin-bottom: 13px;
}
.skel-sub {
  width: 380px;
  max-width: 70%;
  height: 13px;
  margin-bottom: 34px;
}
.skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 28px 19px;
}
.skel-card {
  aspect-ratio: 5 / 7;
  border-radius: 12px;
}

.loading-line {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  height: 2px;
  z-index: 70;
  overflow: hidden;
  pointer-events: none;
}
.loading-line::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 38%;
  background: linear-gradient(90deg, transparent, var(--pink), transparent);
  animation: loadingLine 1s infinite var(--ease);
}

/* ==========================================================================
   详情抽屉
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(28, 22, 25, 0.38);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s var(--ease) both;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 91;
  width: min(570px, 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-2);
  box-shadow: -30px 0 80px rgba(30, 22, 25, 0.22);
  animation: drawerIn 0.38s var(--ease);
}
.drawer-close {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 3;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(26, 22, 25, 0.42);
  backdrop-filter: blur(8px);
  transition:
    background-color 0.16s var(--ease),
    transform 0.16s var(--ease);
}
.drawer-close:hover {
  background: rgba(26, 22, 25, 0.6);
  transform: rotate(90deg);
}
.drawer-close svg {
  width: 16px;
  height: 16px;
}

/* 抽屉右上角：上一条 / 下一条 + 关闭（v3.14）。 */
.drawer-topbar {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer-topbar .drawer-close {
  position: static;
}
.drawer-topbar .drawer-nav button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(26, 22, 25, 0.42);
  backdrop-filter: blur(8px);
}
.drawer-topbar .drawer-nav button:hover:not(:disabled) {
  background: rgba(26, 22, 25, 0.6);
  border-color: transparent;
  color: #fff;
}
.drawer-topbar .drawer-nav button:first-child svg {
  transform: rotate(90deg);
}
.drawer-topbar .drawer-nav button:last-child svg {
  transform: rotate(-90deg);
}

.drawer-hero {
  position: relative;
  min-height: 274px;
  padding: 30px 30px 24px;
  overflow: hidden;
  background: #3d3340;
}
.drawer-hero-bg {
  position: absolute;
  inset: -30px;
  background-image: var(--hero);
  background-size: cover;
  background-position: center;
  filter: blur(34px) saturate(1.25) brightness(0.62);
  transform: scale(1.18);
  opacity: 0.9;
}
.drawer-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(24, 19, 23, 0.18) 0%,
    rgba(24, 19, 23, 0.35) 55%,
    #fbfaf8 100%
  );
}
.drawer-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 21px;
  padding-top: 46px;
}
.drawer-cover {
  position: relative;
  width: 132px;
  flex-shrink: 0;
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(145deg, #d8cfc9, #b9afb0);
  box-shadow:
    0 16px 36px rgba(17, 12, 15, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.15);
}
.drawer-cover img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.drawer-cover .poster-fallback {
  font-size: 32px;
}
.drawer-cover.is-broken img,
.online-cover.is-broken img {
  display: none;
}
.drawer-cover.is-broken .poster-fallback,
.online-cover.is-broken .poster-fallback {
  display: grid;
}
/* 卡片封面与详情共用 /api/cover/:id：源站图片坏掉时同样退回占位，
   与详情抽屉的行为保持一致（否则会看到浏览器的破图标）。 */
.strip-cover.is-broken img,
.ranking-cover.is-broken img,
.compare-poster.is-broken img,
.char-avatar.is-broken img,
.char-subject-cover.is-broken img {
  display: none;
}
.drawer-head-info {
  min-width: 0;
  padding-bottom: 2px;
  color: #fff;
  flex: 1;
}
.drawer-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-number);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.drawer-head h2 {
  font-size: clamp(21px, 3.4vw, 27px);
  font-weight: 760;
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.28);
}
.drawer-alt {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11.5px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.drawer-scoreline {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-top: 13px;
  flex-wrap: wrap;
}
.drawer-score {
  font-family: var(--font-number);
  font-size: 26px;
  font-weight: 750;
  line-height: 1;
  color: #ffe0a8;
  letter-spacing: -0.02em;
}
.drawer-score small {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  margin-left: 4px;
}
.drawer-score-meta {
  color: rgba(255, 255, 255, 0.65);
  font-size: 10.5px;
}
.drawer-rank {
  height: 20px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  background: rgba(255, 214, 139, 0.16);
  color: #ffd88f;
  font-family: var(--font-number);
  font-size: 10px;
  font-weight: 700;
}
.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 14px;
}
.drawer-tag {
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.84);
  font-size: 9.5px;
  backdrop-filter: blur(4px);
}

.drawer-body {
  padding: 9px 30px 54px;
  position: relative;
  z-index: 2;
}
.drawer-section {
  padding: 21px 0;
  border-bottom: 1px solid var(--line);
}
.drawer-section:last-child {
  border-bottom: 0;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-heading h3 {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.section-heading .mini {
  color: var(--faint);
  font-family: var(--font-number);
  font-size: 10px;
}
.summary-text {
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.summary-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.summary-toggle {
  margin-top: 7px;
  color: var(--pink-ink);
  font-size: 10.5px;
  font-weight: 600;
}
.summary-toggle:hover {
  text-decoration: underline;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.fact {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
}
.fact dt {
  color: var(--faint);
  font-size: 9.5px;
  letter-spacing: 0.04em;
}
.fact dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.rating-block {
  display: flex;
  gap: 20px;
  align-items: flex-end;
}
.histogram {
  flex: 1;
  height: 118px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding-top: 18px;
}
.hist-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  position: relative;
}
.hist-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(180deg, #f6aab1, #eb8a94);
  opacity: 0.85;
  transition: opacity 0.15s var(--ease);
}
.hist-col:hover .hist-bar {
  opacity: 1;
}
.hist-label {
  color: var(--faint);
  font-family: var(--font-number);
  font-size: 8.5px;
  line-height: 1;
}
.hist-count {
  position: absolute;
  top: -15px;
  color: transparent;
  font-family: var(--font-number);
  font-size: 8.5px;
  white-space: nowrap;
  transition: color 0.15s var(--ease);
  pointer-events: none;
}
.hist-col:hover .hist-count {
  color: var(--muted);
}
.rating-side {
  flex-shrink: 0;
  width: 92px;
  padding-bottom: 16px;
}
.rating-side strong {
  display: block;
  font-family: var(--font-number);
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1;
}
.rating-side span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.collection-stat {
  padding: 9px 4px;
  text-align: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}
.collection-stat strong {
  display: block;
  font-family: var(--font-number);
  font-size: 13px;
  font-weight: 650;
}
.collection-stat span {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 8.5px;
}

.infobox {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
}
.infobox summary {
  padding: 10px 13px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.infobox summary::-webkit-details-marker {
  display: none;
}
.infobox summary::after {
  content: "展开";
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 400;
}
.infobox[open] summary::after {
  content: "收起";
}
.infobox .info-rows {
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  padding: 4px 13px 8px;
}
.info-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(37, 36, 42, 0.07);
  font-size: 10.5px;
  line-height: 1.6;
}
.info-row:last-child {
  border-bottom: 0;
}
.info-row dt {
  color: var(--faint);
}
.info-row dd {
  margin: 0;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.drawer-actions .btn {
  flex: 1;
}
.drawer-note {
  margin-top: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--pink-wash);
  border: 1px solid rgba(224, 108, 120, 0.14);
  color: var(--pink-ink);
  font-size: 10.5px;
  line-height: 1.65;
}
.deleted-banner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  margin-bottom: 4px;
  border-radius: 9px;
  background: #f4f2ef;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 10.5px;
  line-height: 1.65;
}
.deleted-banner svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--muted);
}

.drawer-loading {
  padding: 40px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   弹窗
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(28, 22, 25, 0.44);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.2s var(--ease) both;
}
.modal {
  width: min(820px, 100%);
  max-height: min(86vh, 860px);
  display: flex;
  flex-direction: column;
  border-radius: 17px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.32s var(--ease) both;
}
.modal.confirm-modal {
  width: min(430px, 100%);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 22px 24px 15px;
}
.modal-head h2 {
  font-size: 19px;
  font-weight: 740;
  letter-spacing: -0.025em;
  line-height: 1.35;
}
.modal-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}
.modal-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(37, 36, 42, 0.05);
}
.modal-close:hover {
  background: rgba(37, 36, 42, 0.09);
  color: var(--ink);
}
.modal-close svg {
  width: 14px;
  height: 14px;
}
.modal-body {
  padding: 0 24px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-foot {
  padding: 14px 24px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.4);
}

.progress-backdrop {
  background: rgba(25, 19, 23, 0.58);
  backdrop-filter: blur(8px);
}
.modal.progress-modal {
  width: min(390px, 100%);
}
.progress-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 28px 26px;
  text-align: center;
}
.progress-illustration {
  position: relative;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}
.progress-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.75), transparent 42%),
    linear-gradient(145deg, var(--pink-wash), var(--surface));
  border: 1px solid var(--line);
  box-shadow:
    0 16px 28px -12px rgba(183, 83, 95, 0.28),
    inset 0 1px 2px rgba(255, 255, 255, 0.7);
}
.progress-ring::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--pink-deep);
  border-right-color: var(--pink);
  animation: spin 1.05s linear infinite;
}
.progress-illustration svg {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  color: var(--pink-ink);
  filter: drop-shadow(0 4px 8px rgba(164, 78, 89, 0.28));
}
.progress-body h2 {
  font-size: 18px;
  font-weight: 740;
  letter-spacing: -0.02em;
}
.progress-message {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.7;
}
.progress-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}
#progress-done {
  margin-top: 18px;
  min-width: 96px;
}
.progress-modal.is-done .progress-ring::before {
  animation: none;
  opacity: 0;
}
.progress-modal.is-done .progress-illustration svg {
  color: var(--green);
}
.progress-modal.is-error .progress-illustration svg {
  color: var(--pink-ink);
}

.online-form {
  display: flex;
  gap: 8px;
  padding: 0 24px 6px;
}
.online-form input {
  flex: 1;
  height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  outline: 0;
}
.online-form input:focus {
  border-color: rgba(224, 108, 120, 0.5);
  box-shadow: 0 0 0 4px rgba(240, 145, 153, 0.1);
}
.online-hint {
  padding: 9px 24px 12px;
  color: var(--faint);
  font-size: 10px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.online-hint svg {
  width: 12px;
  height: 12px;
}
.online-results {
  padding: 2px 24px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.online-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.online-footer .btn {
  flex-shrink: 0;
}
.online-footer .btn[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.58;
}
.online-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.online-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.6);
  transition:
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}
.online-item:hover {
  background: #fff;
  border-color: rgba(224, 108, 120, 0.18);
  box-shadow: var(--shadow-xs);
}
.online-cover {
  position: relative;
  width: 44px;
  aspect-ratio: 5 / 7;
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(145deg, #e5ddd8, #cfc4c4);
  flex-shrink: 0;
}
.online-cover img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.online-cover .poster-fallback {
  font-size: 16px;
}
.online-info {
  min-width: 0;
  flex: 1;
}
.online-info h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-info .alt {
  margin-top: 2px;
  color: var(--faint);
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-info .meta {
  margin-top: 4px;
  display: flex;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 9.5px;
}
.online-item .btn {
  flex-shrink: 0;
}
.online-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--green);
  background: rgba(92, 154, 120, 0.1);
  font-size: 9.5px;
  font-weight: 600;
}
.legacy-tag {
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--amber);
  background: rgba(195, 138, 61, 0.12);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.online-badge.restore {
  color: var(--amber);
  background: rgba(195, 138, 61, 0.12);
}
.online-empty {
  padding: 40px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}
.online-empty svg {
  width: 30px;
  height: 30px;
  margin: 0 auto 10px;
  color: var(--faint);
}

.confirm-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--pink-soft);
  color: var(--pink-deep);
}
.confirm-icon svg {
  width: 18px;
  height: 18px;
}
.confirm-message {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.8;
}
.confirm-message strong {
  color: var(--ink);
  font-weight: 650;
}
.confirm-note {
  margin-top: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #f5f2ee;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}
.reason-input {
  margin-top: 12px;
}
.reason-input label {
  display: block;
  margin-bottom: 5px;
  color: var(--faint);
  font-size: 10px;
}
.reason-input input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  outline: 0;
}
.reason-input input:focus {
  border-color: rgba(224, 108, 120, 0.5);
  box-shadow: 0 0 0 3px rgba(240, 145, 153, 0.1);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  transform: translateX(-50%);
  display: flex;
  /* 选择模式的批量操作条与 toast 同位：批量条出现时把 toast 抬起来，避免互相遮挡。 */
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 520px);
  transition: bottom 0.18s var(--ease);
}
body:has(.bulkbar) .toast-root {
  /* 批量条固定在同一条底边；预留批量条最高两行 + 间距，避免 toast 压在它上面。 */
  bottom: 160px;
}
.toast {
  pointer-events: auto;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(34, 30, 34, 0.95);
  color: #fff;
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  animation: toastIn 0.3s var(--ease) both;
}
.toast.leaving {
  animation: toastOut 0.22s var(--ease) both;
}
.toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #8fd0a9;
}
.toast.error .toast-icon {
  color: #f3a0a8;
}
.toast-action {
  margin-left: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.13);
  color: #ffd4d8;
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}
.toast-action:hover {
  background: rgba(255, 255, 255, 0.2);
}
.toast-close {
  color: rgba(255, 255, 255, 0.45);
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 4px;
}
.toast-close:hover {
  color: #fff;
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1180px) {
  :root {
    --sidebar-w: 212px;
  }
  /* 1024 / 961 一带顶栏是全站最挤的宽度：收紧间距，别让搜索框只剩半截占位文字。 */
  .topbar {
    gap: 14px;
  }
  .header-actions {
    gap: 7px;
  }
  .main {
    padding: 30px 26px 80px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  }
}

@media (max-width: 960px) {
  .menu-btn {
    display: grid;
  }
  .topbar {
    gap: 12px;
    padding: 0 18px;
  }
  .brand-text {
    display: none;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 89;
    width: min(280px, 84vw);
    height: 100vh;
    height: 100dvh;
    padding: 18px 16px 26px;
    background: var(--surface-2);
    box-shadow: 24px 0 60px rgba(30, 22, 25, 0.2);
    transform: translateX(-104%);
    transition: transform 0.32s var(--ease);
  }
  .sidebar.open {
    transform: none;
  }
  .sidebar-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 13px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
  }
  .sidebar-close {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
    background: rgba(37, 36, 42, 0.05);
  }
  .sidebar-close:hover {
    color: var(--ink);
    background: rgba(37, 36, 42, 0.09);
  }
  .sidebar-close svg {
    width: 14px;
    height: 14px;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 88;
    background: rgba(28, 22, 25, 0.36);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease);
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  .main {
    padding: 26px 22px 80px;
  }
  .online-btn span {
    display: none;
  }
  .online-btn {
    width: 38px;
    padding: 0;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    min-height: var(--topbar-base-h);
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 20px;
    border-radius: 9px;
  }
  .search-box {
    order: 10;
    flex-basis: 100%;
    max-width: none;
    height: 38px;
  }
  .search-box kbd {
    display: none;
  }
  .header-actions {
    gap: 6px;
  }
  .main {
    padding: 22px 16px 76px;
  }
  .page-title {
    font-size: 26px;
  }
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .toolbar-group {
    width: 100%;
  }
  .toolbar-group.right {
    justify-content: flex-end;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 24px 14px;
  }
  .facts {
    grid-template-columns: 1fr;
  }
  .drawer-hero {
    padding: 24px 20px 20px;
  }
  .drawer-head {
    padding-top: 42px;
    gap: 14px;
  }
  .drawer-cover {
    width: 104px;
  }
  .drawer-body {
    padding: 4px 20px 42px;
  }
  .drawer-close,
  .drawer-topbar {
    top: 14px;
    right: 14px;
  }
  .modal-backdrop {
    padding: 12px;
    align-items: flex-end;
  }
  .modal {
    max-height: 92vh;
    border-radius: 16px;
  }
  .modal-head {
    padding: 18px 18px 12px;
  }
  .modal-body,
  .online-results {
    padding-left: 18px;
    padding-right: 18px;
  }
  .online-form {
    padding-left: 18px;
    padding-right: 18px;
  }
  .online-hint,
  .online-footer {
    padding-left: 18px;
    padding-right: 18px;
  }
  .online-item {
    gap: 9px;
    padding: 7px;
  }
  .online-cover {
    width: 38px;
  }
  .online-item .btn {
    height: 30px;
    padding: 0 9px;
    font-size: 10px;
  }
  .toast-root {
    bottom: 82px;
  }
  .bulkbar {
    bottom: 14px;
  }
}

@media (max-width: 430px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 11px;
  }
  /* 列表视图在手机上不再给操作按钮单独一列：正文只剩 80px，标题和元信息会挤成竖条。 */
  .grid.list-view .card {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      "poster body"
      "poster actions";
    align-items: start;
    row-gap: 8px;
  }
  .grid.list-view .poster {
    align-self: start;
  }
  .grid.list-view .card-actions {
    align-self: end;
    justify-self: end;
  }
  .card-title {
    font-size: 12px;
  }
  .card-alt {
    font-size: 9.5px;
  }
  .card-meta {
    font-size: 9px;
  }
  .page-sub {
    font-size: 11px;
  }
  .toolbar-label {
    display: none;
  }
  .collection-grid {
    gap: 3px;
  }
  .collection-stat strong {
    font-size: 11px;
  }
  .collection-stat span {
    font-size: 7.5px;
  }
}

@media (hover: none) {
  .card-actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    background: linear-gradient(transparent, rgba(16, 13, 15, 0.4));
    padding-top: 14px;
  }
  .card-action {
    height: 25px;
  }
  .card:hover .poster {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    /* 卡片入场带 stagger 延迟且初始透明；不清掉延迟仍会等最多 360ms 才出现。 */
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  /* 加载转圈若只转一圈就停，看起来像卡死；保留一个缓慢的旋转作为进行中提示。 */
  .loader-ring {
    animation: spin 1.6s linear infinite !important;
  }
}

/* ==========================================================================
   动画
   ========================================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes drawerIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: none;
  }
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes bulkIn {
  from {
    opacity: 0;
    transform: translate(-50%, 14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes emptyFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
@keyframes emptyIconFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}
@keyframes loadingLine {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(360%);
  }
}

@keyframes loaderBar {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(260%);
  }
}

/* ==========================================================================
   加载提示 / 删除标记 / 标签工具
   ========================================================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: rgba(247, 245, 242, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.15s var(--ease) both;
}

.loading-card {
  width: min(280px, 82vw);
  padding: 24px 24px 21px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 16px;
  border: 1px solid rgba(37, 36, 42, 0.08);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
}

.loader-ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(240, 145, 153, 0.2);
  border-top-color: var(--pink-deep);
  animation: spin 0.8s linear infinite;
}

.loading-label {
  margin-top: 14px;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.6;
}
.loading-detail {
  margin-top: 3px;
  max-width: 100%;
  overflow: hidden;
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-track {
  width: 100%;
  height: 3px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(37, 36, 42, 0.07);
}
.loading-track i {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--pink), transparent);
  animation: loaderBar 1.1s infinite var(--ease);
}

.deleted-ribbon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: 23px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(90deg, #c94f5b, #d9636e);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  box-shadow: 0 -2px 8px rgba(160, 50, 60, 0.18);
}
.card.is-deleted .card-actions {
  bottom: 31px;
}
.card.is-deleted .select-toggle {
  opacity: 0.85;
}
.grid.list-view .card.is-deleted .card-actions {
  bottom: auto;
}
.grid.list-view .deleted-ribbon {
  height: 17px;
  font-size: 8px;
  letter-spacing: 0.05em;
}

.card-action.restore {
  color: var(--green);
  background: rgba(240, 250, 244, 0.95);
}
.card-action.restore:hover {
  background: #effaf3;
}
.card-action.purge {
  flex: 0 0 27px;
  padding: 0;
  color: #b34e59;
  background: rgba(255, 246, 247, 0.94);
}
.card-action.purge .purge-text {
  display: none;
}
.card-action.purge:hover {
  background: #fff0f2;
}
.grid.list-view .card-actions .card-action.purge {
  flex: 0 0 auto;
  padding: 0 11px;
  background: var(--pink-soft);
}
.grid.list-view .card-actions .card-action.purge .purge-text {
  display: inline;
}
.grid.list-view .card-actions .card-action.purge:hover {
  background: #fff0f2;
}

.tag-empty {
  padding: 3px 4px;
  color: var(--faint);
  font-size: 10px;
}
.tag-modal {
  width: min(720px, 100%);
}
.tag-modal-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 24px 14px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
.tag-modal-search svg {
  width: 15px;
  height: 15px;
  color: var(--faint);
  flex-shrink: 0;
}
.tag-modal-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12px;
}
/* 输入框本身去掉了 outline，焦点提示画在外框上（与 .search-box / .compare-search 一致）。 */
.tag-modal-search:focus-within {
  border-color: rgba(224, 108, 120, 0.48);
  box-shadow: 0 0 0 3px rgba(240, 145, 153, 0.12);
}
.tag-modal-results {
  padding: 0 24px 26px;
  overflow-y: auto;
  min-height: 120px;
  max-height: 58vh;
}
.tag-modal-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.tag-modal-cloud .tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 5px 9px;
}
.tag-modal-cloud .tag-chip span {
  color: var(--faint);
  font-family: var(--font-number);
  font-size: 9px;
}
/* ==========================================================================
   搜索范围提示
   ========================================================================== */

.search-scope-hint {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-wrap: wrap;
  margin: -8px 0 18px;
  padding: 11px 13px;
  border: 1px solid rgba(224, 108, 120, 0.2);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(253, 239, 241, 0.86), rgba(255, 255, 255, 0.55));
}
.search-scope-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--pink-deep);
  background: var(--pink-soft);
}
.search-scope-icon svg {
  width: 14px;
  height: 14px;
}
.search-scope-copy {
  min-width: 0;
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.search-scope-copy strong {
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
}
.search-scope-copy span {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.search-scope-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.search-scope-btn {
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(224, 108, 120, 0.28);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--pink-ink);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}
.search-scope-btn svg {
  width: 11px;
  height: 11px;
}
.search-scope-btn:hover {
  background: #fff;
  border-color: rgba(224, 108, 120, 0.5);
  box-shadow: var(--shadow-xs);
}

@media (max-width: 720px) {
  .search-scope-hint {
    align-items: flex-start;
  }
  .search-scope-actions {
    width: 100%;
    margin-left: 41px;
  }
}

@media (max-width: 720px) {
  .loading-card {
    padding: 20px 18px 17px;
    border-radius: 14px;
  }
  .loader-ring {
    width: 32px;
    height: 32px;
  }
  .tag-modal {
    max-height: 92vh;
  }
  .tag-modal-search {
    margin: 0 14px 12px;
  }
  .tag-modal-results {
    padding: 0 14px 18px;
    max-height: 62vh;
  }
  .tag-modal-cloud .tag-chip {
    font-size: 10.5px;
    padding: 5px 8px;
  }
  .deleted-ribbon {
    height: 21px;
    font-size: 9px;
  }
  .card.is-deleted .card-actions {
    bottom: 28px;
  }
}

/* --------------------------------------------------------------------------
   部署版只读态：写操作入口仅对管理员显示。
   服务端仍会对所有写接口做会话 + CSRF 校验，这里的隐藏只负责界面。
   -------------------------------------------------------------------------- */
body:not(.admin) #site-mode,
body:not(.admin) .online-btn,
body:not(.admin) [data-action="toggle-select"],
body:not(.admin) [data-action="online-search"],
body:not(.admin) [data-action="fetch-subject-characters"],
body:not(.admin) [data-action="purge-all-deleted"],
body:not(.admin) [data-action="scan-orphan-subjects"],
body:not(.admin) [data-action="delete"],
body:not(.admin) [data-action="purge"],
body:not(.admin) [data-action="restore"],
body:not(.admin) [data-action="character-delete"],
body:not(.admin) [data-action="character-restore"],
body:not(.admin) [data-action="import"],
body:not(.admin) [data-action="online-more"],
body:not(.admin) [data-action="select-all"],
body:not(.admin) [data-action="bulk-state"],
body:not(.admin) [data-action="bulk-delete"],
body:not(.admin) [data-action="bulk-purge"],
body:not(.admin) [data-action="bulk-restore"],
body:not(.admin) [data-action="bulk-cancel"] {
  display: none !important;
}

.admin-login-modal {
  width: min(440px, calc(100vw - 32px));
}

.admin-login-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.admin-login-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.admin-login-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

.form-error {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--danger, #b34e59);
  font-size: 12.5px;
}
body:not(.admin) [data-action="show-deleted"],
body:not(.admin) [data-action="purge-all-deleted"] { display: none !important; }
body:not(.admin) .show-deleted { display: none !important; }

/* 收藏、评分和观看状态对普通访客可见，但不能通过点击修改。
   只保留“已收藏/当前观看状态”的只读指示，未收藏的空按钮不显示。 */
body:not(.admin) [data-action="toggle-favorite"],
body:not(.admin) [data-action="set-watch"],
body:not(.admin) [data-action="character-favorite"] {
  display: inline-flex !important;
  pointer-events: none;
  cursor: default;
}
body:not(.admin) [data-action="toggle-favorite"][aria-pressed="false"],
body:not(.admin) [data-action="set-watch"][aria-pressed="false"],
body:not(.admin) [data-action="character-favorite"][aria-pressed="false"] {
  display: none !important;
}
body:not(.admin) [data-action="set-watch"][data-status="unwatched"] { display: none !important; }
