:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --primary: #4a9eff;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Header ===== */
.site-header {
  background: #111;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 20px;
  gap: 16px;
}
.site-logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-logo:hover { color: #fff; }
.logo-img { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; }

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  padding: 6px;
  margin-right: -6px;
  flex-shrink: 0;
}
.hamburger-btn:hover { color: #fff; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.header-nav a {
  color: #bbb;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.header-nav a:hover,
.header-nav a.active { color: #fff; background: rgba(255,255,255,0.06); }

.header-search { margin-left: auto; }
.header-search-form input,
.header-search input {
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 180px;
  transition: border-color .15s, width .2s;
}
.header-search-form input:focus,
.header-search input:focus { border-color: #444; width: 220px; }
.header-search-form input::placeholder,
.header-search input::placeholder { color: #666; }

.mode-switch-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, #4a9eff 0%, #6366f1 100%);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(74,158,255,0.3);
  transition: all .25s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.mode-switch-btn:hover { box-shadow: 0 4px 18px rgba(74,158,255,0.45); opacity: 0.92; }
.mode-switch-btn:active { opacity: 0.85; }
.mode-switch-btn svg { flex-shrink: 0; }

/* mobile sidebar overlay */
.mobile-nav-overlay { display: none; }
.mobile-nav-panel { display: none; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  text-align: center;
  font-size: 12px;
  color: #666;
}
.site-footer .wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
.site-footer a { color: #888; text-decoration: none; }
.site-footer a:hover { color: var(--primary); }
.footer-sep { margin: 0 8px; color: #444; }

/* ===== Index: Hero ===== */
.main-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px 20px;
}
.hero {
  text-align: center;
  padding: 48px 20px 40px;
}
.hero h1 {
  font-size: 36px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}
.hero-desc {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ===== Index: Sections ===== */
.section-block { margin-bottom: 44px; }
.block-title {
  font-size: 18px;
  font-weight: 700;
  color: #ddd;
  margin-bottom: 16px;
  padding-left: 4px;
  border-left: 3px solid var(--primary);
}

/* ===== Index: IDX cards ===== */
.idx-card-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.idx-card-row::-webkit-scrollbar { height: 4px; }
.idx-card-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.idx-card {
  flex: 0 0 220px;
  scroll-snap-align: start;
  background-color: #1a1a2e;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .2s, transform .2s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 140px;
  position: relative;
  overflow: hidden;
}
.idx-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.6) 100%);
  z-index: 0;
  pointer-events: none;
}
.idx-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.hc-body { position: relative; z-index: 1; padding: 16px 16px 8px; }
.hc-body h3 { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-body p { font-size: 13px; color: rgba(255,255,255,0.7); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hc-meta { position: relative; z-index: 1; padding: 8px 16px 16px; font-size: 12px; color: rgba(255,255,255,0.5); display: flex; gap: 12px; }

/* ===== Index: Recommended links ===== */
.rec-link-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.rec-link-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; text-decoration: none; color: var(--text); font-size: 14px;
  transition: border-color .2s, background .2s;
}
.rec-link-item:hover { border-color: var(--primary); background: #1e1e1e; }
.rec-link-icon { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.rec-link-txt {
  width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.rec-link-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

/* ===== Index: Category layout ===== */
.category-layout { display: flex; gap: 28px; align-items: flex-start; }
.cat-sidebar {
  flex: 0 0 160px; max-width: 160px; position: sticky; top: 68px;
  display: flex; flex-direction: column; gap: 2px;
}
.cat-nav-link {
  font-size: 13px; color: var(--text-muted); text-decoration: none;
  padding: 8px 14px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .15s, background .15s;
}
.cat-nav-link:hover, .cat-nav-link:target { color: var(--primary); background: rgba(74,158,255,0.08); }
.cat-content { flex: 1; min-width: 0; }
.cat-group { margin-bottom: 32px; }
.cat-group-title {
  font-size: 15px; font-weight: 700; color: #ccc; margin-bottom: 12px;
  position: sticky; top: 52px; background: var(--bg); padding: 8px 0; z-index: 10;
}
.cat-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.cat-link-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  text-decoration: none; color: var(--text); font-size: 14px; transition: border-color .2s, background .2s;
}
.cat-link-item:hover { border-color: var(--primary); background: #1e1e1e; }
.cat-link-icon {
  width: 28px; height: 28px; border-radius: 7px; background: rgba(74,158,255,0.15);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  color: var(--primary); flex-shrink: 0; overflow: hidden;
}
.cat-link-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; }
.cat-link-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Index: Mode prompt ===== */
.mode-prompt-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.mode-prompt {
  background: #1e1e2e; border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 32px; max-width: 400px; width: 100%; text-align: center;
  animation: promptIn .3s ease;
}
@keyframes promptIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.prompt-icon {
  width: 60px; height: 60px; margin: 0 auto 16px;
  background: rgba(74,158,255,0.1); border-radius: 16px;
  display: flex; align-items: center; justify-content: center; color: var(--primary);
}
.mode-prompt h3 { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.mode-prompt p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }
.prompt-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-primary {
  padding: 12px 24px; background: var(--primary); color: #fff; border: none;
  border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: #5bb0ff; }
.btn-ghost {
  padding: 10px 24px; background: none; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: #555; }

/* ===== Detail: Breadcrumb ===== */
.breadcrumb-wrap { max-width: 1200px; margin: 0 auto; padding: 14px 20px 0; }
.breadcrumb { font-size: 13px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: #555; }

/* ===== Detail: Page layout ===== */
.page-wrap {
  max-width: 1200px; margin: 0 auto; padding: 24px 20px 40px;
  display: grid; grid-template-columns: 1fr 320px; gap: 32px;
}
.sidebar { order: 1; }
.primary h1 { font-size: 28px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.primary .bio { font-size: 15px; color: var(--text-muted); margin-bottom: 24px; }
.link-sections { margin-top: 8px; }
.link-section { margin-bottom: 28px; }
.link-section h2 { font-size: 16px; font-weight: 600; color: #ccc; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.link-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.link-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  text-decoration: none; color: var(--text); font-size: 14px; transition: border-color .15s, background .15s;
}
.link-item:hover { border-color: var(--primary); background: #1e1e1e; }
.link-item .icon {
  width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; color: #fff;
}
.link-item .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Detail: Sidebar ===== */
.sidebar-inner { position: sticky; top: 72px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.info-card .stat-row { display: flex; gap: 0; text-align: center; margin-bottom: 16px; border-radius: 8px; overflow: hidden; }
.info-card .stat-row .stat { flex: 1; padding: 10px 4px; background: rgba(255,255,255,0.03); }
.info-card .stat .num { display: block; font-size: 20px; font-weight: 700; color: #fff; }
.info-card .stat .lbl { display: block; font-size: 11px; color: #777; margin-top: 2px; }
.info-card .meta { font-size: 13px; color: #999; }
.info-card .meta p { margin-bottom: 6px; }
.info-card .meta strong { color: #bbb; font-weight: 500; }
.btn-preview { display: block; text-align: center; margin-top: 16px; padding: 10px 0; background: var(--primary); color: #fff; text-decoration: none; border-radius: 8px; font-size: 14px; font-weight: 600; transition: background .15s; }
.btn-preview:hover { background: #5bb0ff; }

/* ===== Detail: Related homes ===== */
.related-wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px 48px; }
.related-wrap h2 { font-size: 18px; font-weight: 600; color: #ccc; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.related-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.related-list a { display: block; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); transition: border-color .15s; }
.related-list a:hover { border-color: var(--primary); }
.related-list .rtitle { font-size: 14px; font-weight: 600; color: #ddd; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.related-list .rdesc { font-size: 12px; color: #777; }

/* ===== Detail: Home card list (type / search) ===== */
.home-card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.home-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px;
  background-color: #1a1a2e;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border); border-radius: 10px;
  text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s;
  position: relative; overflow: hidden; min-height: 140px; justify-content: flex-end;
}
.home-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.55) 100%);
  z-index: 0; pointer-events: none;
}
.home-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.home-card-title { position: relative; z-index: 1; font-weight: 600; color: #ddd; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-card-meta { position: relative; z-index: 1; font-size: 12px; color: rgba(255,255,255,0.6); }
.home-card-bio { position: relative; z-index: 1; font-size: 12px; color: rgba(255,255,255,0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Detail: Pager ===== */
.pager { margin-top: 32px; text-align: center; display: flex; justify-content: center; align-items: center; gap: 8px; }
.pager-link { padding: 8px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13px; transition: border-color .15s; }
.pager-link:hover { border-color: var(--primary); }
.pager-info { padding: 8px 0; color: #888; font-size: 13px; }
.empty-hint { color: var(--text-muted); text-align: center; padding: 60px 0; }

/* ===== 移动端适配 (≤768px) ===== */
@media (max-width: 768px) {
  body { min-width: 320px; }

  /* header */
  .site-header .wrap { gap: 8px; height: 48px; padding: 0 12px; }
  .hamburger-btn { display: block; }
  .header-nav { display: none; }
  .site-logo { font-size: 15px; gap: 6px; }
  .site-logo img { width: 20px; height: 20px; }
  .header-search { margin-left: auto; }
  .header-search-form input, .header-search input { width: 100px; padding: 6px 10px; font-size: 12px; }
  .header-search-form input:focus, .header-search input:focus { width: 120px; }

  /* mode switch */
  .mode-switch-btn { width: 34px; height: 34px; padding: 0; font-size: 0; gap: 0; border-radius: 50%; justify-content: center; flex-shrink: 0; }
  .mode-switch-btn svg { width: 16px; height: 16px; }

  /* mobile sidebar */
  .mobile-nav-overlay {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 300; opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .mobile-nav-overlay.open { opacity: 1; pointer-events: auto; }
  .mobile-nav-panel {
    display: block; position: fixed; top: 0; left: 0; bottom: 0; width: 260px; max-width: 80vw;
    background: #12121a; z-index: 301; transform: translateX(-100%);
    transition: transform .25s ease; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .mobile-nav-overlay.open .mobile-nav-panel { transform: translateX(0); }
  .mobile-nav-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 700; color: #fff; }
  .mobile-nav-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; padding: 4px; line-height: 1; }
  .mobile-nav-close:hover { color: #fff; }
  .mobile-nav-links { display: flex; flex-direction: column; padding: 10px 0; }
  .mobile-nav-links a { color: #bbb; text-decoration: none; font-size: 14px; padding: 12px 20px; transition: color .15s, background .15s; }
  .mobile-nav-links a:hover, .mobile-nav-links a.active { color: #fff; background: rgba(255,255,255,0.05); }

  /* index */
  .main-wrap { padding: 20px 12px 16px; }
  .hero { padding: 28px 8px 24px; }
  .hero h1 { font-size: 22px; margin-bottom: 8px; }
  .hero-desc { font-size: 13px; line-height: 1.6; }
  .section-block { margin-bottom: 28px; }
  .block-title { font-size: 15px; margin-bottom: 10px; padding-left: 6px; border-left-width: 2px; }
  .idx-card-row { gap: 10px; padding-bottom: 6px; }
  .idx-card { flex: 0 0 150px; min-height: 100px; border-radius: 10px; }
  .hc-body { padding: 10px 10px 6px; }
  .hc-body h3 { font-size: 13px; margin-bottom: 4px; }
  .hc-body p { font-size: 11px; }
  .hc-meta { padding: 4px 10px 12px; font-size: 10px; gap: 8px; }
  .rec-link-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .rec-link-item { padding: 8px 8px; font-size: 11px; gap: 5px; border-radius: 8px; flex-direction: column; text-align: center; }
  .rec-link-icon, .rec-link-txt { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }
  .rec-link-name { font-size: 10px; max-width: none; white-space: normal; word-break: break-all; }
  .category-layout { gap: 12px; }
  .cat-sidebar { flex: 0 0 72px; max-width: 72px; font-size: 11px; top: 56px; gap: 1px; }
  .cat-nav-link { padding: 8px 6px; font-size: 11px; border-radius: 6px; }
  .cat-group { margin-bottom: 20px; }
  .cat-group-title { font-size: 13px; margin-bottom: 8px; top: 48px; }
  .cat-link-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
  .cat-link-item { padding: 8px 10px; font-size: 12px; gap: 6px; }
  .cat-link-icon { width: 24px; height: 24px; font-size: 11px; border-radius: 6px; }
  .site-footer { padding: 10px 0; font-size: 11px; }
  .mode-prompt { padding: 24px 18px; max-width: 90vw; }
  .mode-prompt h3 { font-size: 16px; }
  .mode-prompt p { font-size: 13px; }
  .btn-primary { padding: 10px 20px; font-size: 14px; }
  .btn-ghost { padding: 8px 20px; font-size: 13px; }

  /* detail pages */
  .page-wrap { grid-template-columns: 1fr; }
  .sidebar { order: 0; }
  .sidebar-inner { position: static; }
  .link-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .link-item { padding: 8px 12px; font-size: 13px; gap: 8px; }
  .info-card .stat-row { flex-wrap: wrap; }
  .related-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .home-card-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ===== 超小屏 (≤400px) ===== */
@media (max-width: 400px) {
  .hero h1 { font-size: 18px; }
  .hero-desc { font-size: 12px; }
  .idx-card { flex: 0 0 130px; min-height: 90px; }
  .idx-card-row { gap: 8px; }
  .hc-body h3 { font-size: 12px; }
  .cat-group-title { top: 48px; }
  .cat-sidebar { flex: 0 0 60px; max-width: 60px; }
  .cat-link-grid { grid-template-columns: 1fr 1fr; }
}
