/* ============================================================
   追剧么指南 — 样式
   配色沿用原站的 shadcn neutral 风格，支持浅色 / 深色
   ============================================================ */

:root {
  --background: 0 0% 100%;
  --foreground: 0 0% 3.9%;
  --card: 0 0% 100%;
  --muted: 0 0% 96.1%;
  --muted-foreground: 0 0% 45.1%;
  --border: 0 0% 89.8%;
  --accent: 0 0% 96.1%;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 20px 40px -12px rgb(0 0 0 / 0.25);
}

.dark {
  --background: 0 0% 3.9%;
  --foreground: 0 0% 98%;
  --card: 0 0% 5.9%;
  --muted: 0 0% 14.9%;
  --muted-foreground: 0 0% 63.9%;
  --border: 0 0% 16.5%;
  --accent: 0 0% 14.9%;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.7);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .2s, color .2s;
}

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

.ico { width: 16px; height: 16px; flex: none; }
.ico-sm { width: 14px; height: 14px; }

/* ---------------- 布局骨架 ---------------- */
.container {
  max-width: 1024px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 32px 16px 0;
}

@media (min-width: 640px) { .container { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 1024px) { .container { padding-left: 32px; padding-right: 32px; } }

/* ---------------- 头部 ---------------- */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.header-logo {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 4px;
  object-fit: contain;
}

.header-title {
  min-width: 0;
  flex: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-nav { display: flex; align-items: center; gap: 12px; }

.header-nav a {
  color: hsl(var(--muted-foreground) / 0.55);
  display: flex;
  transition: color .15s;
}
.header-nav a:hover { color: hsl(var(--muted-foreground)); }
.header-nav svg { width: 16px; height: 16px; }

/* ---------------- 统计 + 工具条 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 12px;
}

.stats { font-size: 12px; color: hsl(var(--muted-foreground)); line-height: 1.35; }
.stats b { font-weight: 600; color: hsl(var(--foreground) / 0.75); }

.controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / 0.4);
  flex: none;
}

.ctrl-divider { width: 1px; height: 16px; margin: 0 2px; background: hsl(var(--border)); }

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.ctrl-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.ctrl-btn.is-on { background: hsl(var(--accent)); color: hsl(var(--foreground)); }

/* ---------------- 分类标签 ---------------- */
.tabs-wrap { display: flex; justify-content: space-between; margin-bottom: 24px; }

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px;
  padding: 4px;
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  background: hsl(var(--muted) / 0.4);
}

.tab {
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.tab:hover { background: hsl(var(--accent) / 0.6); color: hsl(var(--foreground)); }
.tab.is-active { background: hsl(var(--foreground)); color: hsl(var(--background)); }

.tab .tab-count {
  margin-left: 5px;
  font-size: 10px;
  opacity: .55;
}

@media (max-width: 639px) {
  #tabs.tabs {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-radius: 12px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  #tabs.tabs::-webkit-scrollbar { display: none; }

  #tabs.tabs .tab {
    flex: 0 0 auto;
    padding: 8px 12px;
  }
}

/* ---------------- 卡片网格 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, background-color .2s, box-shadow .2s, transform .2s;
}
.card:hover {
  border-color: hsl(var(--foreground) / 0.15);
  background: hsl(var(--accent) / 0.5);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
@media (min-width: 640px) { .card { gap: 14px; padding: 16px; } }

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: hsl(var(--muted));
  transition: background-color .2s;
}
@media (min-width: 640px) { .card-icon { width: 40px; height: 40px; border-radius: 12px; } }

.card-icon img { width: 20px; height: 20px; border-radius: 6px; object-fit: contain; }
@media (min-width: 640px) { .card-icon img { width: 24px; height: 24px; } }
.card-icon svg { width: 14px; height: 14px; color: hsl(var(--muted-foreground)); }
@media (min-width: 640px) { .card-icon svg { width: 16px; height: 16px; } }

.card-body { min-width: 0; flex: 1; }

.card-name {
  display: block;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 640px) { .card-name { font-size: 14px; } }

.card-desc {
  margin: 2px 0 0;
  font-size: 10px;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 640px) { .card-desc { font-size: 12px; } }

.card-badge {
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  background: hsl(var(--foreground) / 0.08);
  color: hsl(var(--muted-foreground));
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
}

/* 空状态 */
.empty {
  grid-column: 1 / -1;
  padding: 48px 0;
  text-align: center;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

/* ---------------- 页脚 ---------------- */
.footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 0 16px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.footer-section { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.footer-label {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .02em;
  color: hsl(var(--muted-foreground) / 0.5);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
}

.footer-nav a {
  font-size: 11px;
  color: hsl(var(--muted-foreground) / 0.65);
  transition: color .15s;
}
.footer-nav a:hover { color: hsl(var(--foreground)); }

.footer-sponsors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 24px;
}

.footer-sponsors a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: hsl(var(--muted-foreground) / 0.65);
  transition: color .15s;
}
.footer-sponsors a:hover { color: hsl(var(--foreground)); }
.footer-sponsors img {
  height: 24px;
  width: auto;
  max-width: 112px;
  object-fit: contain;
  opacity: .5;
  filter: grayscale(1);
  transition: opacity .2s, filter .2s;
}
.footer-sponsors a:hover img { opacity: 1; filter: grayscale(0); }

.footer-copyright {
  margin: 0;
  font-size: 11px;
  text-align: center;
  color: hsl(var(--muted-foreground) / 0.6);
  line-height: 1.7;
}
.footer-copyright a { text-decoration: underline; text-underline-offset: 3px; }
.footer-copyright a:hover { color: hsl(var(--foreground)); }

/* ---------------- 搜索面板 ---------------- */
.palette { position: fixed; inset: 0; z-index: 50; }

.palette-mask {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  backdrop-filter: blur(2px);
  animation: fade-in .12s ease-out;
}

.palette-panel {
  position: relative;
  width: calc(100% - 32px);
  max-width: 560px;
  margin: 10vh auto 0;
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--card));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in .14s ease-out;
}

@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.985) } to { opacity: 1; transform: none } }

.palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}

.palette-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 14px;
}
.palette-search input::placeholder { color: hsl(var(--muted-foreground) / 0.7); }

.palette-kbd {
  flex: none;
  padding: 2px 6px;
  border: 1px solid hsl(var(--border));
  border-radius: 5px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 10px;
  font-family: inherit;
}

.palette-results {
  max-height: 56vh;
  overflow-y: auto;
  padding: 6px;
  overscroll-behavior: contain;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color .1s;
}
.palette-item:hover,
.palette-item.is-active { background: hsl(var(--accent)); }

.palette-item .pi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  background: hsl(var(--muted));
}
.palette-item .pi-icon img { width: 17px; height: 17px; border-radius: 4px; object-fit: contain; }
.palette-item .pi-icon svg { width: 13px; height: 13px; color: hsl(var(--muted-foreground)); }

.palette-item .pi-body { min-width: 0; flex: 1; }
.palette-item .pi-name { font-size: 13px; font-weight: 500; }
.palette-item .pi-name em,
.palette-item .pi-desc em { font-style: normal; background: hsl(var(--foreground) / 0.12); border-radius: 3px; padding: 0 2px; }
.palette-item .pi-desc {
  margin: 1px 0 0;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-item .pi-cat {
  flex: none;
  font-size: 10px;
  color: hsl(var(--muted-foreground) / 0.7);
}

.palette-empty {
  padding: 28px 0;
  text-align: center;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

.palette-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.35);
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}

/* ---------------- 减少动效偏好 ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
