:root {
  --bg: #0f0f0f;
  --panel: #161616;
  --card: #1a1a1a;
  --card-hover: #222;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --text-dim: #888;
  --text-faint: #5a5a5a;
  --accent: #5b8cff;
  --accent-dim: #2d3f6b;
  --accent2: #39d3a0;
  --warn: #f2b14c;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; white-space: nowrap; }
.logo { font-size: 20px; }
.search-wrap { flex: 1; max-width: 560px; }
#search {
  width: 100%; padding: 9px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
#search:focus { outline: none; border-color: var(--accent); }
.actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn {
  display: inline-flex; align-items: center;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 13px;
  transition: background 0.15s, border-color 0.15s; white-space: nowrap;
}
.btn:hover { background: var(--card-hover); border-color: #3a3a3a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.lang-select {
  padding: 7px 8px; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}

/* 视图切换：主站 / 全部页面 */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { padding: 8px 12px; background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; transition: background 0.15s, color 0.15s; white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; }
.sidebar { position: sticky; top: 78px; align-self: start; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 98px); overflow-y: auto; }

.mode-menu { display: flex; flex-direction: column; gap: 6px; }
.mode-btn { text-align: left; padding: 11px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer; font-size: 14px; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.mode-btn:hover { background: var(--card); color: var(--text); }
.mode-btn.active { background: linear-gradient(120deg, rgba(91,140,255,.16), rgba(57,211,160,.08)); border-color: var(--accent); color: var(--text); font-weight: 600; }

.stats, .cat-nav { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }

.card .rank { font-family: monospace; font-size: 11px; color: var(--text-faint); flex-shrink: 0; width: 22px; text-align: right; }
.section.reco .card .rank { color: var(--accent); }
.stats h3, .cat-nav h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin-bottom: 10px; }
.stat-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-dim); }
.stat-row b { color: var(--text); }
.sources { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.src-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-dim); color: #cdd9ff; }

.cat-nav ul { list-style: none; }
.cat-nav li { padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer; display: flex; justify-content: space-between; }
.cat-nav li:hover { background: var(--card); color: var(--text); }
.cat-nav li .count { font-size: 11px; color: var(--text-faint); }
.cat-nav li.hol-item { justify-content: flex-start; gap: 8px; font-size: 13px; }
.cat-nav li.hol-item .hd { color: #ff7a7a; min-width: 38px; font-variant-numeric: tabular-nums; }

/* ---------- 主区 ---------- */
.main { min-width: 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty .howto { max-width: 460px; margin: 24px auto 0; text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.empty .howto summary { cursor: pointer; color: var(--accent); }
.empty .howto ol { margin: 10px 0 0 18px; color: var(--text-dim); }
.empty .howto li { margin: 4px 0; }

.progress { margin-bottom: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.progress .bar { height: 6px; background: var(--card); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.progress-msg { margin-top: 8px; font-size: 12px; color: var(--text-dim); }

.reco-topbar { margin-bottom: 12px; }
.reco-region .seg-btn { font-size: 13px; }
.reco-banner { margin-bottom: 22px; padding: 12px 16px; border-radius: var(--radius); background: linear-gradient(120deg, rgba(91,140,255,.10), rgba(57,211,160,.06)); border: 1px solid var(--border2); color: var(--text-dim); font-size: 13px; }

/* ---------- 日历 ---------- */
.cal-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-region .seg-btn { font-size: 13px; }
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-nav .cal-year { font-size: 22px; font-weight: 700; min-width: 70px; text-align: center; }
.cal-legend { font-size: 12px; color: var(--text-dim); margin-bottom: 18px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.cal-legend .note { color: var(--text-faint); }
.cal-legend .rk-term { cursor: help; border-bottom: 1px dotted var(--text-faint); }
.cal-legend .rk-term:hover { color: var(--text); border-bottom-color: var(--accent); }
.cal-tbl td .rk { cursor: help; }
.cal-tbl td .rk.em { color: var(--accent2); font-weight: 600; }
.cal-tbl td .ev { display: block; font-size: 8.5px; color: var(--warn); line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-nav li.ev-item .hd { color: var(--warn); }
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cal-month { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 12px 8px; }
.cal-mh { font-size: 15px; font-weight: 600; margin-bottom: 8px; padding-left: 2px; }
.cal-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-tbl th { font-size: 11px; font-weight: 500; color: var(--text-dim); padding: 3px 0; }
.cal-tbl th.sun { color: #ff7a7a; } .cal-tbl th.sat { color: #6ab0ff; }
.cal-tbl td { height: 46px; vertical-align: top; padding: 3px 2px; border: 1px solid var(--border); border-radius: 4px; }
.cal-tbl td.empty { border: none; }
.cal-tbl td .dn { font-size: 13px; font-weight: 600; }
.cal-tbl td .rk { display: block; font-size: 9px; color: var(--text-faint); line-height: 1.1; }
.cal-tbl td .hn { display: block; font-size: 8.5px; color: #ff7a7a; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-tbl td.sun .dn { color: #ff7a7a; } .cal-tbl td.sat .dn { color: #6ab0ff; }
.cal-tbl td.today { background: var(--accent-dim); border-color: var(--accent); }
.cal-tbl td.hol { background: rgba(255, 122, 122, .07); }

.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; font-weight: 600; }
.section-head .meta { font-size: 12px; color: var(--text-faint); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }

.card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  min-width: 0;
}
.card:hover { background: var(--card-hover); border-color: #3a3a3a; transform: translateY(-1px); }
.card .fav { width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0; background: #2a2a2a; object-fit: contain; }
.card .body { min-width: 0; flex: 1; overflow: hidden; }
.card .name { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .domain { display: block; font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .badge { font-size: 11px; color: var(--text-dim); flex-shrink: 0; white-space: nowrap; }
.card .star { color: #f2c94c; font-size: 12px; }

.section.top .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.section.top .card { background: linear-gradient(135deg, #1c2336, var(--card)); }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 18px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.toast.err { border-color: #6b2d2d; color: #ffb4b4; }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .actions .btn { padding: 8px 10px; }
}
