:root {
  --bg: #f7f8fa;
  --text: #222;
  --muted: #6b7280;
  --primary: #1677ff;
  --primary-hover: #0958d9;
  --card: #eef5ff;
  --row: #fff;
  --border: #e8e8e8;
  --channel-bg: #f4f0ff;
  --channel-border: #7c6fe0;
  --ok: #389e0d;
  --warn: #d48806;
  --full: #8c8c8c;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  overflow-x: hidden;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(48px, calc(24px + env(safe-area-inset-bottom)));
}

/* SEO: real H1 for crawlers; intro copy lives at bottom */
.seo-header {
  margin: 0 0 16px;
}

.seo-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.seo-desc {
  margin: 16px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
}

.rec-heading {
  margin: 0 0 6px;
  font-size: clamp(1.05rem, 4vw, 1.2rem);
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card.recommend {
  background: var(--card);
  border-radius: 12px;
  padding: 28px 24px;
  margin-bottom: 28px;
}

.rec-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.rec-text {
  min-width: 0;
  flex: 1;
}



.gid {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.avatar {
  display: block;
  object-fit: cover;
  background: #e5e7eb;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 14px;
}

.avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.group-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

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

.btn.primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  z-index: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn.primary .btn-text {
  position: relative;
  z-index: 2;
}

/*
 * 无缝炫彩：色带重复两份，transform 只平移 50%。
 * 用 linear + translate 避免 background-position 来回拉造成的顿挫。
 */
.btn.primary.chroma {
  background: transparent;
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.28);
}

.btn.primary.chroma::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  /* 两倍宽 + 两段相同色带，平移 50% 后视觉与起点完全一致 */
  width: 200%;
  z-index: 0;
  background: linear-gradient(
    90deg,
    #ff4d4f,
    #fa8c16,
    #fadb14,
    #52c41a,
    #13c2c2,
    #1677ff,
    #722ed1,
    #eb2f96,
    #ff4d4f,
    #fa8c16,
    #fadb14,
    #52c41a,
    #13c2c2,
    #1677ff,
    #722ed1,
    #eb2f96,
    #ff4d4f
  );
  animation: chroma-slide 3s linear infinite;
  pointer-events: none;
  will-change: transform;
}

/* 高光扫过：同样用位移做周期循环 */
.btn.primary.chroma::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  z-index: 1;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 40%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0.15) 60%,
    transparent 100%
  );
  animation: chroma-shine 2.5s linear infinite;
  pointer-events: none;
  will-change: transform;
}

.btn.primary.chroma:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 16px rgba(114, 46, 209, 0.35);
}

.btn.primary.chroma:active {
  filter: brightness(0.98);
}

@keyframes chroma-slide {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes chroma-shine {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(350%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn.primary.chroma::before,
  .btn.primary.chroma::after {
    animation: none;
  }
  .btn.primary.chroma::before {
    width: 100%;
    background: var(--primary);
    background-size: auto;
    transform: none;
  }
  .btn.primary.chroma::after {
    display: none;
  }
  .btn.primary.chroma {
    box-shadow: none;
  }
}

.redirect-status {
  margin: 14px 0 0;
  min-height: 1.25em;
}

.linkish {
  margin-top: 4px;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 8px 0;
  min-height: 44px;
  font-size: 0.9rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.linkish:hover {
  text-decoration: underline;
}

.block {
  margin-bottom: 28px;
}

.block h2 {
  font-size: 1rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.channels {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-item {
  display: block;
  padding: 14px 16px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--channel-bg);
  color: #5b4fc9;
  text-decoration: none;
  font-weight: 500;
  border-left: 3px solid var(--channel-border);
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.channel-item:hover {
  filter: brightness(0.98);
}

.groups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-item {
  background: var(--row);
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  min-width: 0;
}

.group-item a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.group-item a:hover {
  text-decoration: underline;
}

.group-item.full a {
  color: var(--full);
  pointer-events: none;
  text-decoration: none;
}

.group-item.recommended {
  border-color: #91caff;
  background: #f0f7ff;
}

.group-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px 12px;
}

.group-main {
  min-width: 0;
  flex: 1 1 auto;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 4px;
  background: #e6f4ff;
  color: #1677ff;
  vertical-align: middle;
  white-space: nowrap;
}

.status {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}

.status.available {
  color: var(--ok);
}

.status.nearly_full {
  color: var(--warn);
}

.status.full {
  color: var(--full);
}

.bar {
  margin-top: 8px;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

.bar.full > span {
  background: var(--full);
}

.bar.nearly_full > span {
  background: var(--warn);
}

.counts {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta {
  margin-top: 12px;
}

.footer-tip {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.error {
  margin: 0;
  color: #cf1322;
}

.hidden {
  display: none !important;
}

/* 手机竖屏 */
@media (max-width: 480px) {
  .page {
    padding-top: 16px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(32px, calc(16px + env(safe-area-inset-bottom)));
  }

  .card.recommend {
    padding: 20px 16px;
    margin-bottom: 20px;
    border-radius: 10px;
  }

  .rec-header {
    margin-bottom: 16px;
  }

  .avatar-lg {
    width: 56px;
    height: 56px;
    border-radius: 12px;
  }

  .btn.primary {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.95rem;
  }

  .btn.primary .btn-text {
    text-align: center;
  }

  .block {
    margin-bottom: 22px;
  }

  .block h2 {
    font-size: 0.95rem;
  }

  .channel-item {
    padding: 14px 14px;
  }

  .group-item {
    padding: 12px;
  }

  .group-top {
    gap: 6px 10px;
  }

  .footer-tip {
    font-size: 0.82rem;
    padding: 12px;
  }

  .meta {
    font-size: 0.8rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }
}

/* 很窄的屏（小屏安卓 / 分屏） */
@media (max-width: 360px) {
  body {
    font-size: 14px;
  }

  .recommend h1 {
    font-size: 1.05rem;
  }

  .btn.primary {
    font-size: 0.9rem;
    padding: 12px 12px;
  }

  .badge {
    margin-left: 4px;
    font-size: 0.7rem;
  }
}

/* 横屏手机：少占纵向空间 */
@media (max-height: 480px) and (orientation: landscape) {
  .page {
    padding-top: 12px;
    padding-bottom: 20px;
  }

  .card.recommend {
    padding: 16px 18px;
    margin-bottom: 16px;
  }

  .gid {
    margin-bottom: 12px;
  }
}
