:root {
  --bg: #f4f4f0;
  --panel: #fff;
  --panel-soft: #fafaf7;
  --ink: #191a18;
  --muted: #858781;
  --line: #e8e8e2;
  --accent: #ff5a3c;
  --accent-soft: #fff0eb;
  --sidebar: #ededE8;
  --shadow: 0 14px 38px rgba(22, 24, 20, .055);
  --radius: 18px;
}

html[data-theme="dark"] {
  --bg: #141513;
  --panel: #1e201d;
  --panel-soft: #242622;
  --ink: #f1f1eb;
  --muted: #999c94;
  --line: #30322e;
  --accent-soft: #3a211c;
  --sidebar: #191b18;
  --shadow: 0 16px 40px rgba(0,0,0,.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.noise {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 236px; padding: 30px 22px 22px;
  background: var(--sidebar); border-right: 1px solid var(--line); z-index: 30;
  display: flex; flex-direction: column;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 34px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 21px; font-weight: 700; letter-spacing: -.04em; }
.brand-mark { width: 28px; height: 29px; display: flex; align-items: end; gap: 3px; padding: 4px; border-radius: 8px; background: var(--ink); transform: rotate(-2deg); }
.brand-mark i { width: 4px; border-radius: 4px; background: var(--bg); display: block; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; background: var(--accent); }
.brand-mark i:nth-child(3) { height: 12px; }
.nav-group { margin-bottom: 25px; }
.nav-label { margin: 0 10px 9px; color: var(--muted); font: 600 11px/1 "DM Sans", sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.nav-item, .source-link {
  width: 100%; border: 0; background: none; display: flex; align-items: center; gap: 11px;
  border-radius: 10px; cursor: pointer; text-align: left; transition: .2s ease;
}
.nav-item { min-height: 45px; padding: 0 11px; color: #6f716c; font-size: 14px; font-weight: 500; }
.nav-item:hover, .source-link:hover { color: var(--ink); background: color-mix(in srgb, var(--panel) 62%, transparent); }
.nav-item.active { background: var(--panel); color: var(--ink); box-shadow: 0 5px 14px rgba(20,21,19,.04); }
.nav-icon { font: 600 18px/1 "DM Sans", sans-serif; width: 19px; color: var(--muted); }
.nav-item b { margin-left: auto; border-radius: 20px; padding: 2px 7px; background: var(--panel-soft); color: var(--muted); font: 600 10px "DM Sans"; }
.source-link { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.source-link span { display: grid; place-items: center; width: 25px; height: 25px; flex: none; border-radius: 8px; color: #fff; background: var(--dot); font-size: 10px; font-weight: 700; }
.sidebar-card { margin-top: auto; padding: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 62%, transparent); border-radius: 13px; display: flex; align-items: center; gap: 10px; }
.pulse-dot { position: relative; width: 8px; height: 8px; flex: none; border-radius: 50%; background: #3bbb77; box-shadow: 0 0 0 5px rgba(59,187,119,.12); }
.sidebar-card strong, .sidebar-card small { display: block; }
.sidebar-card strong { font-size: 13px; }
.sidebar-card small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.sidebar-footer { margin: 14px 5px 0; color: var(--muted); font-size: 10px; text-align: center; }
.close-menu, .mobile-header, .scrim { display: none; }

.page-shell { margin-left: 236px; padding: 58px clamp(28px, 5vw, 76px) 30px; max-width: 1700px; }
.hero { min-height: 240px; display: flex; justify-content: space-between; align-items: flex-start; gap: 40px; padding-bottom: 40px; }
.eyebrow { margin: 0 0 20px; color: var(--muted); font: 700 10px "DM Sans", sans-serif; letter-spacing: .18em; }
.eyebrow span { display: inline-block; width: 27px; height: 1px; margin: 0 10px 3px 0; background: var(--accent); }
.hero h1 { margin: 0; font-size: clamp(36px, 4.3vw, 62px); line-height: 1.13; letter-spacing: -.055em; font-weight: 700; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero-copy { max-width: 540px; margin: 20px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.hero-meta { display: flex; flex-direction: column; align-items: center; gap: 13px; padding-top: 15px; }
.date-card { width: 110px; height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); transform: rotate(2deg); }
.date-card span { color: var(--accent); font: 700 10px "DM Sans"; letter-spacing: .18em; }
.date-card strong { margin: 2px 0 -2px; font: 700 49px/1 "DM Sans"; letter-spacing: -.06em; }
.date-card small { color: var(--muted); font-size: 10px; }
.live-caption { color: var(--muted); font-size: 11px; white-space: nowrap; }
.live-caption i { display: inline-block; width: 5px; height: 5px; margin: 0 5px 1px 0; border-radius: 50%; background: #3bbb77; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.filters, .toolbar-actions { display: flex; align-items: center; gap: 7px; }
.filter-chip { padding: 8px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; transition: .2s ease; }
.filter-chip:hover { color: var(--ink); }
.filter-chip.active { background: var(--ink); color: var(--bg); }
.search-box { width: 200px; height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 8px 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.search-box svg, .icon-button svg, .refresh-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.search-box svg { color: var(--muted); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search-box input::placeholder { color: var(--muted); }
.search-box kbd { padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--panel-soft); font: 8px "DM Sans"; }
.icon-button, .refresh-button { height: 34px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; border-radius: 9px; transition: .2s ease; }
.icon-button { width: 36px; display: grid; place-items: center; }
.refresh-button { display: flex; align-items: center; gap: 6px; padding: 0 13px; font-size: 12px; }
.icon-button:hover, .refresh-button:hover { border-color: var(--muted); transform: translateY(-1px); }
.refresh-button.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.summary-row { display: flex; justify-content: space-between; align-items: center; margin: 26px 2px 14px; color: var(--muted); font-size: 12px; }
.summary-row p { margin: 0; }
.summary-row strong { color: var(--ink); font: 700 13px "DM Sans"; }
.ranking-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.ranking-card { min-width: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(0,0,0,.01); transition: .25s ease; }
.ranking-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-head { height: 76px; display: flex; align-items: center; padding: 0 18px; border-bottom: 1px solid var(--line); }
.source-logo { width: 35px; height: 35px; display: grid; place-items: center; flex: none; margin-right: 11px; border-radius: 10px; color: #fff; background: var(--source-color); font: 700 13px "DM Sans", sans-serif; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.source-title { min-width: 0; }
.source-title strong { display: block; font-size: 15px; }
.source-title small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-live { width: 5px; height: 5px; margin-left: 6px; display: inline-block; border-radius: 50%; background: #3bbb77; }
.favorite-button { margin-left: auto; width: 27px; height: 27px; border: 0; border-radius: 7px; background: transparent; color: #b6b8b2; cursor: pointer; font-size: 17px; }
.favorite-button:hover, .favorite-button.active { color: var(--accent); background: var(--accent-soft); }
.rank-list { margin: 0; padding: 6px 16px 9px; list-style: none; }
.rank-item { min-height: 43px; display: grid; grid-template-columns: 27px minmax(0,1fr) auto; align-items: center; gap: 5px; border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }
.rank-item:last-child { border: 0; }
.rank-number { color: #b5b7b1; font: 600 11px "DM Sans"; }
.rank-item:nth-child(1) .rank-number { color: #ff4c32; }
.rank-item:nth-child(2) .rank-number { color: #ff842c; }
.rank-item:nth-child(3) .rank-number { color: #eeb52c; }
.rank-link { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; transition: color .15s; }
.rank-link:hover { color: var(--accent); }
.rank-hot { margin-left: 7px; color: var(--muted); font: 500 10px "DM Sans", sans-serif; white-space: nowrap; }
.card-foot { height: 43px; padding: 0 17px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); background: var(--panel-soft); }
.card-foot span { color: var(--muted); font-size: 10px; }
.expand-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.expand-button:hover { color: var(--accent); }
.ranking-card.expanded .rank-item:nth-child(n+9) { display: grid; }
.rank-item:nth-child(n+9) { display: none; }
.fallback-badge { color: #db8b24 !important; }

.skeleton-card { height: 438px; position: relative; background: linear-gradient(105deg, var(--panel) 35%, var(--panel-soft) 44%, var(--panel) 55%); background-size: 220% 100%; animation: shimmer 1.25s infinite linear; }
@keyframes shimmer { to { background-position-x: -220%; } }
.empty-state { padding: 75px 20px; text-align: center; }
.empty-state span { font-size: 38px; color: var(--muted); }
.empty-state h2 { margin: 12px 0 5px; font-size: 17px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.empty-state button { padding: 9px 14px; border: 0; border-radius: 8px; background: var(--ink); color: var(--bg); cursor: pointer; font-size: 10px; }
.page-footer { margin-top: 50px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.page-footer p { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 50; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; padding: 10px 16px; border-radius: 9px; color: var(--bg); background: var(--ink); font-size: 12px; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .ranking-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .search-box { width: auto; flex: 1; }
}

@media (max-width: 760px) {
  .mobile-header { position: sticky; top: 0; z-index: 20; height: 62px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); }
  .mobile-header .brand { font-size: 18px; }
  .mobile-header .brand-mark { transform: scale(.87); }
  .sidebar { transform: translateX(-101%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .close-menu { display: block; border: 0; background: none; color: var(--muted); font-size: 23px; cursor: pointer; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(12,13,12,.35); backdrop-filter: blur(2px); }
  .scrim.show { display: block; }
  .page-shell { margin-left: 0; padding: 30px 17px 24px; }
  .hero { min-height: 215px; gap: 15px; }
  .hero-copy { font-size: 13px; }
  .hero-meta { padding-top: 5px; }
  .date-card { width: 82px; height: 100px; }
  .date-card strong { font-size: 38px; }
  .ranking-grid { grid-template-columns: 1fr; }
  .filters { width: 100%; overflow-x: auto; }
  .toolbar-actions { flex-wrap: wrap; }
  .search-box { order: -1; flex-basis: 100%; }
  .refresh-button { margin-left: auto; }
  .summary-row span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
