/* ============================================================
   China Trending — styles
   Dark theme by default; light theme via html[data-theme="light"]
   ============================================================ */

:root {
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --rank1: #ff4d4f;
  --rank2: #ff9f43;
  --rank3: #ffd93d;
  --ok: #2ecc71;
  --danger: #f0506e;
  --radius: 14px;
  --sidebar-w: 280px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-0: #080c18;
  --bg-1: #0d1326;
  --bg-2: #111a31;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #e9edf6;
  --text-dim: #9aa5bb;
  --text-faint: #67718c;
  --item-hover: rgba(59, 130, 246, 0.10);
  --active-grad: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --glow-1: rgba(37, 99, 235, 0.20);
  --glow-2: rgba(124, 58, 237, 0.16);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-0: #eef2f9;
  --bg-1: #f6f8fd;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-2: rgba(255, 255, 255, 0.9);
  --border: rgba(15, 23, 42, 0.10);
  --border-soft: rgba(15, 23, 42, 0.07);
  --text: #182036;
  --text-dim: #5a647c;
  --text-faint: #8b93a8;
  --item-hover: rgba(37, 99, 235, 0.07);
  --active-grad: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --shadow: 0 10px 30px rgba(30, 41, 82, 0.12);
  --glow-1: rgba(37, 99, 235, 0.10);
  --glow-2: rgba(124, 58, 237, 0.08);
}

* { box-sizing: border-box; }

/* visually hidden but crawlable (for the page's single H1) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 48%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ambient glow blobs */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}
body::before {
  width: 560px; height: 560px;
  top: -180px; left: -120px;
  background: var(--glow-1);
}
body::after {
  width: 640px; height: 640px;
  bottom: -240px; right: -160px;
  background: var(--glow-2);
}

a { color: inherit; }

/* ---------------- layout ---------------- */

.app {
  display: flex;
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------------- sidebar ---------------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  flex: none;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 40;
  transition: transform 0.28s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 14px;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s;
}
.brand:hover { opacity: 0.85; }
.brand-logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 24px;
  border-radius: 12px;
  background: var(--active-grad);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.search-box { padding: 4px 16px 12px; }
.search-box input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-faint); }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 12px;
  scrollbar-width: thin;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-group { margin: 10px 0 4px; }
.nav-group-label {
  padding: 10px 10px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 2px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item .nav-icon { font-size: 16px; width: 22px; text-align: center; flex: none; }
.nav-item .nav-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-zh { font-size: 11px; color: var(--text-faint); flex: none; }

.nav-item.active {
  background: var(--active-grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}
.nav-item.active .nav-zh { color: rgba(255, 255, 255, 0.75); }

/* static external-link group shown below the boards list */
.nav-links {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border-soft);
}
.nav-links .nav-group { margin-top: 0; }
.nav-links .nav-item .nav-zh { font-weight: 700; }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.foot-note { font-size: 11px; color: var(--text-faint); line-height: 1.4; }

.theme-btn {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.15s;
}
.theme-btn:hover { transform: scale(1.06); }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.55);
  z-index: 30;
}

/* ---------------- main ---------------- */

.main {
  flex: 1;
  padding: 0 26px 30px;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 4px;
  background: linear-gradient(180deg, var(--bg-0) 0%, var(--bg-0) 55%, transparent 100%);
}

.burger {
  display: none;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--active-grad);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex: none;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.45);
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.burger:hover { transform: scale(1.06); box-shadow: 0 6px 18px rgba(59, 130, 246, 0.55); }
.burger:active { transform: scale(0.94); }

.clock { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.updated { font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 2px;
  background: var(--text-faint);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #fff; }

.interval {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.countdown { font-size: 12.5px; color: var(--text-dim); min-width: 118px; text-align: right; font-variant-numeric: tabular-nums; }

.refresh-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.25s ease;
}
.refresh-btn:hover { transform: rotate(180deg); }
.refresh-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ---------------- board header ---------------- */

.board-head {
  margin: 18px 0 20px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.board-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 21px;
  font-weight: 700;
}
.board-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 22px;
  border-radius: 12px;
  background: var(--active-grad);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}
.board-zh {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-faint);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  padding: 3px 10px;
  border-radius: 999px;
}
.board-desc { margin-top: 10px; font-size: 13.5px; color: var(--text-dim); line-height: 1.6; }
.board-meta { margin-top: 10px; font-size: 12px; color: var(--text-faint); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.board-meta a { color: var(--accent); text-decoration: none; }
.board-meta a:hover { text-decoration: underline; }

/* ---------------- list ---------------- */

.list-wrap { max-width: 900px; margin: 0 auto; }

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

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.item:hover {
  background: var(--item-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}

.rank {
  flex: none;
  width: 34px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-faint);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rank.r1 { color: var(--rank1); font-size: 18px; }
.rank.r2 { color: var(--rank2); font-size: 17px; }
.rank.r3 { color: var(--rank3); font-size: 16px; }

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

.item-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  text-decoration: none;
}
.item-title:hover { color: var(--accent); }
.item-title .arrow { opacity: 0; margin-left: 6px; font-size: 12px; transition: opacity 0.15s; }
.item-title:hover .arrow { opacity: 0.7; }

.item-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.item-sub .zh { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 1px 6px;
  opacity: 0.9;
}

.item-desc {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-hot {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.item-hot .flame { opacity: 0.85; }

/* ---------------- states ---------------- */

.status {
  padding: 26px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 14px;
}
.status.error { color: var(--danger); border-color: var(--danger); }
.status .retry {
  margin-top: 12px;
  padding: 8px 18px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.status .retry:hover { border-color: var(--accent); color: var(--accent); }

.skeleton {
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  height: 62px;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--panel-2), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ---------------- footer ---------------- */

.foot {
  margin: 30px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  max-width: 900px;
}

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main { margin-left: 0; padding: 0 14px 24px; }
  .burger { display: block; }
  .clock { display: none; }
  .topbar { gap: 10px; }
  .updated { display: none; }
  .item { padding: 12px 12px; gap: 10px; }
  .board-head { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
