/* ═══════════ 主题变量 ═══════════ */
:root {
  --bg: #fbfbfc;
  --card-bg: #ffffff;
  --card-hover: #f7f7f9;
  --text: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-tertiary: #a1a1a6;
  --accent: #5b5fc7;
  --accent-soft: rgba(91,95,199,0.08);
  --border: #e8e8ec;
  --border-strong: #d8d8dd;
  --radius: 8px;
  --radius-sm: 6px;
  --transition: all 0.18s ease;
}

[data-theme="dark"] {
  --bg: #0f0f11;
  --card-bg: #18181b;
  --card-hover: #1f1f23;
  --text: #e4e4e7;
  --text-secondary: #9d9da3;
  --text-tertiary: #6b6b70;
  --accent: #7c7ff0;
  --accent-soft: rgba(124,127,240,0.14);
  --border: #27272a;
  --border-strong: #3a3a3f;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}
a { color: inherit; text-decoration: none; }
.glass { background: var(--card-bg); }

/* ═══════════ 顶部导航 ═══════════ */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(251,251,252,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .header { background: rgba(15,15,17,0.82); }
.header-inner {
  max-width: 1120px; margin: 0 auto;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 16px;
}
.logo {
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text); white-space: nowrap;
}
.search-box { flex: 1; position: relative; }
.search-box input {
  width: 100%; padding: 7px 34px 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text);
  font-size: 13px; font-family: inherit; outline: none;
  transition: var(--transition);
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon {
  position: absolute; right: 11px; top: 50%;
  transform: translateY(-50%);
  font-size: 12px; color: var(--text-tertiary);
  pointer-events: none;
}
.btn-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; color: var(--text-secondary);
  transition: var(--transition);
}
.btn-icon:hover {
  background: var(--card-hover); color: var(--text);
  border-color: var(--border-strong);
}

/* ═══════════ 主内容区 ═══════════ */
.main { max-width: 1120px; margin: 0 auto; padding: 20px; }
.section { margin-bottom: 22px; }
.section-title {
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 10px;
  display: flex; align-items: center; gap: 5px;
}

/* ═══════════ ① 名站导航（265密集风格） ═══════════ */
.famous-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 2px 10px;
  padding: 10px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.famous-link {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text-secondary);
  transition: var(--transition);
  overflow: hidden;
}
.famous-link:hover {
  background: var(--card-hover);
  color: var(--accent);
}
.famous-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  border-radius: 3px;
  object-fit: contain;
  background: #fff;
}
.famous-icon-fb {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  color: #fff; border-radius: 3px;
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.famous-name {
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0;
}

/* ═══════════ ② 分类导航（表格样式） ═══════════ */
.category-table {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 16px;
}
.category-row {
  display: grid;
  grid-template-columns: 62px 1fr 48px;
  gap: 14px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.category-row:last-child { border-bottom: none; }
.category-name {
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  padding-top: 1px;
  display: flex; align-items: center; gap: 4px;
}
.category-name .cat-icon { font-size: 13px; }
.category-sites {
  display: flex; flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 12.5px; line-height: 1.7;
}
.category-sites a {
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
}
.category-sites a:hover { color: var(--accent); }
.category-more {
  font-size: 12px; color: var(--text-tertiary);
  white-space: nowrap; padding-top: 2px;
  text-align: right;
}
.category-more:hover { color: var(--accent); }

/* ═══════════ ③ 实时热搜 ═══════════ */
.hot-list {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.hot-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  font-size: 12.5px; color: var(--text-secondary);
  overflow: hidden;
  transition: var(--transition);
}
.hot-item:hover { color: var(--accent); }
.hot-num {
  flex-shrink: 0;
  min-width: 16px; height: 16px;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
  color: var(--text-tertiary);
}
.hot-item:nth-child(1) .hot-num { background: #e5484d; color: #fff; }
.hot-item:nth-child(2) .hot-num { background: #f76b15; color: #fff; }
.hot-item:nth-child(3) .hot-num { background: #e8a33d; color: #fff; }
.hot-item > span:last-child {
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════ ④ 天气 + 万年历 ═══════════ */
.dashboard-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 22px;
}
@media (max-width: 900px) {
  .dashboard-row { grid-template-columns: 1fr; }
}
.widget-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.widget-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
  gap: 8px; flex-wrap: wrap;
}
.widget-header h3 {
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}

/* 天气 */
.city-search { display: flex; gap: 4px; }
.city-search input {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text);
  font-size: 11px; font-family: inherit;
  outline: none; width: 100px;
  transition: var(--transition);
}
.city-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.city-search button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 11px; cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.city-search button:hover {
  background: var(--card-hover); color: var(--text);
  border-color: var(--border-strong);
}
.weather-content {
  display: flex; align-items: center; gap: 14px;
  padding: 2px 0 10px;
}
.weather-icon { font-size: 26px; line-height: 1; }
.weather-temp {
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1; color: var(--text);
}
.weather-city-name {
  font-size: 12px; font-weight: 500;
  color: var(--text); margin-bottom: 2px;
}
.weather-desc {
  font-size: 11px; color: var(--text-secondary);
  margin-top: 1px;
}
.weather-extra {
  display: flex; gap: 12px;
  font-size: 11px; color: var(--text-tertiary);
  margin-top: 5px;
}
.weather-loading {
  font-size: 12px; color: var(--text-tertiary);
  padding: 8px 0;
}
.weather-forecast {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.forecast-day {
  text-align: center; padding: 6px 2px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.forecast-day:hover { background: var(--card-hover); }
.forecast-day .fd-name {
  font-size: 10px; color: var(--text-tertiary);
  margin-bottom: 3px;
}
.forecast-day .fd-icon { font-size: 14px; }
.forecast-day .fd-temp {
  font-size: 10px; color: var(--text-secondary);
  margin-top: 2px;
}

/* 万年历 */
.calendar-nav {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-secondary);
  font-weight: 500;
}
.cal-btn {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  font-size: 14px; line-height: 1; cursor: pointer;
  color: var(--text-tertiary);
  border-radius: 4px; font-family: inherit;
  transition: var(--transition);
}
.cal-btn:hover { background: var(--card-hover); color: var(--text); }
.calendar-lunar-today {
  font-size: 11px; color: var(--accent);
  font-weight: 500; margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: inline-block;
}
.calendar-grid { width: 100%; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 10px;
  color: var(--text-tertiary);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; margin-top: 4px;
}
.cal-day {
  text-align: center; padding: 4px 1px;
  border-radius: 4px; font-size: 11px;
  color: var(--text); cursor: default;
  min-height: 32px;
  transition: var(--transition);
  position: relative;
}
.cal-day:hover { background: var(--card-hover); }
.cal-day.other-month { color: var(--text-tertiary); opacity: 0.5; }
.cal-day.today {
  background: var(--accent); color: #fff;
  font-weight: 600;
}
.cal-day .lunar-text {
  display: block; font-size: 9px;
  line-height: 1.1;
  color: var(--text-tertiary);
  margin-top: 1px;
  transform: scale(0.95);
}
.cal-day.today .lunar-text { color: rgba(255,255,255,0.85); }
.cal-day.festival .lunar-text { color: #e5484d; font-weight: 500; }
.cal-day.today.festival .lunar-text { color: #ffd5d6; }

/* ═══════════ 新闻面板 ═══════════ */
.news-panel {
  max-width: 1120px; margin: 0 auto 16px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeInUp 0.25s ease both;
}
.news-panel-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
}
.news-list { display: flex; flex-direction: column; }
.news-item {
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: var(--transition);
}
.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--card-hover); }
.news-item .news-title {
  font-size: 12.5px; font-weight: 500;
  line-height: 1.5; margin-bottom: 3px;
  color: var(--text);
}
.news-item:hover .news-title { color: var(--accent); }
.news-item .news-meta {
  font-size: 10.5px; color: var(--text-tertiary);
  display: flex; gap: 12px;
}

/* ═══════════ 页脚 & 返回顶部 ═══════════ */
.footer {
  max-width: 1120px; margin: 24px auto 0;
  padding: 20px; text-align: center;
  font-size: 11px; color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}
.back-to-top {
  position: fixed; bottom: 24px; right: 24px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px; cursor: pointer;
  opacity: 0; pointer-events: none; z-index: 99;
  transition: var(--transition);
}
.back-to-top.show { opacity: 1; pointer-events: auto; }
.back-to-top:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ═══════════ 动画 & 响应式 ═══════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .header-inner { padding: 8px 14px; gap: 10px; }
  .main { padding: 14px; }
  .famous-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    padding: 8px;
  }
  .category-row {
    grid-template-columns: 52px 1fr;
    gap: 8px;
  }
  .category-more { display: none; }
  .hot-list { grid-template-columns: 1fr; }
  .weather-forecast { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .logo { font-size: 13px; }
  .search-box input { padding: 6px 30px 6px 10px; font-size: 12px; }
  .weather-temp { font-size: 20px; }
  .weather-icon { font-size: 22px; }
  .famous-grid { grid-template-columns: repeat(2, 1fr); }
  .category-sites { gap: 2px 10px; font-size: 12px; }
}