/* =========================================================================
 * 小金屋网址导航 - 样式
 * 设计目标：三栏布局 / 卡片尺寸完全统一(v40) / 响应式 / 浅色主题
 * ========================================================================= */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --border: #e6eaf2;
  --text: #1f2733;
  --text-soft: #5b6675;
  --text-mute: #9aa4b2;
  --primary: #ff6a3d;       /* 小金屋主色：暖橙 */
  --primary-soft: #fff1ea;
  --primary-d: #e8552a;
  --accent: #2f6bff;
  --shadow: 0 2px 12px rgba(31, 39, 51, .06);
  --shadow-h: 0 8px 28px rgba(31, 39, 51, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1320px;
  /* 卡片统一尺寸（v40 核心） */
  --card-h: 86px;
  --card-w: 100%;
}

/* ============ 暗色主题（v=zx） ============ */
:root[data-theme="dark"] {
  --bg: #0f1320;
  --surface: #171c2c;
  --surface-2: #1f2638;
  --border: #2a3247;
  --text: #e6e9f0;
  --text-soft: #aab2c4;
  --text-mute: #717b90;
  --primary: #ff7a4d;
  --primary-soft: #2a1a12;
  --primary-d: #ff8a5c;
  --accent: #5b8cff;
  --shadow: 0 2px 12px rgba(0,0,0,.45);
  --shadow-h: 0 8px 28px rgba(0,0,0,.6);
}
/* 暗色下覆盖写死的白底 */
:root[data-theme="dark"] .search input:focus { background: var(--surface); }
:root[data-theme="dark"] .kbd { background: var(--surface-2); color: var(--text-soft); }
:root[data-theme="dark"] .btn { background: var(--surface); }
:root[data-theme="dark"] .sort-tabs button.active { background: var(--surface); }
:root[data-theme="dark"] .detail-hero { background: linear-gradient(135deg, var(--surface), var(--primary-soft)); }
:root[data-theme="dark"] .detail-hero .fav-big { background: var(--surface-2); }
:root[data-theme="dark"] .pager button { background: var(--surface); }
/* 顶部栏在暗色下使用深色背景（覆盖写死的半透明白） */
:root[data-theme="dark"] .header { background: rgba(15,19,32,.92); }
:root[data-theme="dark"] .ad-top { background: #0f1320; }
/* 后台内联样式里写死的白底，暗色下统一覆盖 */
:root[data-theme="dark"] body { color: var(--text); }
:root[data-theme="dark"] .ad-nav { background: var(--surface); }
:root[data-theme="dark"] .ad-panel { background: var(--surface); }
:root[data-theme="dark"] .ad-banner { background: var(--primary-soft); color: var(--primary-d); border-color: #ffd0bd; }
:root[data-theme="dark"] .mini { background: var(--surface); }
:root[data-theme="dark"] .modal { background: var(--surface); }
:root[data-theme="dark"] .login { background: var(--surface); }
:root[data-theme="dark"] .ad-toolbar input:focus,
:root[data-theme="dark"] .ad-toolbar select:focus { background: var(--bg); }
:root[data-theme="dark"] .form-row input:focus,
:root[data-theme="dark"] .form-row textarea:focus,
:root[data-theme="dark"] .form-row select:focus { background: var(--surface-2); }
:root[data-theme="dark"] table.ad tr:hover td { background: var(--surface-2); }
:root[data-theme="dark"] .x:hover { background: var(--primary-soft); color: var(--primary-d); }

/* 主题切换按钮 */
.theme-toggle {
  position: fixed; right: 16px; bottom: 80px; z-index: 900;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 20px; display: grid; place-items: center;
  box-shadow: var(--shadow-h); transition: transform .15s, background .15s;
}
.theme-toggle:hover { transform: scale(1.08); background: var(--surface-2); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- Header ---------------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; white-space: nowrap; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #ffb347);
  display: grid; place-items: center; color: #fff; font-size: 18px;
}
.logo small { display:block; font-size: 11px; font-weight: 500; color: var(--text-mute); }
.search {
  flex: 1; position: relative; max-width: 560px;
}
.search input {
  width: 100%; height: 42px; border: 1px solid var(--border);
  border-radius: 999px; padding: 0 120px 0 44px;
  background: var(--surface-2); font-size: 14px; outline: none;
  transition: .2s;
}
.search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search .ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.search .kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-mute); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 7px; background: #fff; user-select: none;
}
.header-actions { display: flex; gap: 10px; }
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  transition: .18s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); color: #fff; }

/* ---------------- Layout ---------------- */
.layout {
  max-width: var(--maxw); margin: 18px auto; padding: 0 20px;
  display: grid; grid-template-columns: 220px minmax(0,1fr) 300px; gap: 20px;
  align-items: start;
}
.sidebar { position: sticky; top: 78px; }
.sidebar.right { position: static; }   /* 右栏内容全部显示，不裁切、无下拉条 */
.sidebar.right #friendlyGrid.card-grid { display: flex; flex-direction: column; align-items: center; gap: 12px; }  /* 友链：单列、居中、接近外框满宽 */
.sidebar.right #friendlyGrid.card-grid .card { width: 96%; height: auto; min-height: 60px; padding: 14px 16px; }  /* 放大并只比外框窄一点 */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.panel + .panel { margin-top: 16px; }
.panel-title {
  font-size: 13px; font-weight: 700; color: var(--text-soft);
  margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between;
}
.panel-title .count { font-weight: 500; color: var(--text-mute); font-size: 12px; }

/* 站点统计：指标卡 + 访问动态 */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; }
.stat-cell { text-align: center; padding: 8px 4px; background: var(--surface-2); border-radius: 10px; }
.stat-cell .num { font-size: 22px; font-weight: 800; color: var(--primary-d); line-height: 1.1; }
.stat-cell .lbl { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.stat-extra { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--text-mute); }
.stat-extra b { color: var(--primary-d); font-weight: 800; margin-left: 2px; }

/* 热门分类 Top5（占比条） */
.cat-rank { display: flex; flex-direction: column; gap: 9px; }
.cr-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cr-name { flex: none; width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.cr-bar { flex: 1; height: 7px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.cr-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--primary), var(--primary-d)); }
.cr-num { flex: none; width: 30px; text-align: right; font-weight: 800; color: var(--primary-d); }

/* 左侧分类 */
.cat-filter { position: relative; margin-bottom: 10px; }
.cat-filter input {
  width: 100%; height: 34px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px 0 30px; font-size: 13px; outline: none; background: var(--surface-2);
}
.cat-filter .ico { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.cat-list { list-style: none; margin: 0; padding: 0; }   /* 显示全部分类，不出现左侧下拉条 */
.cat-list li { margin: 2px 0; }
.cat-list a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: 9px; color: var(--text-soft); font-size: 13.5px; font-weight: 600;
  transition: .15s;
}
.cat-list a .emoji { font-size: 15px; }
.cat-list a .num { margin-left: auto; font-size: 11px; color: var(--text-mute); font-weight: 500; }
.cat-list a:hover { background: var(--surface-2); color: var(--text); }
.cat-list a.active { background: var(--primary-soft); color: var(--primary-d); }

/* 右侧 */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a {
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft); transition: .15s;
}
.tag-cloud a:hover { background: var(--primary-soft); color: var(--primary-d); }
.tag-cloud a b { color: var(--primary); font-weight: 700; margin-left: 3px; font-size: 11px; }

.hot-search { list-style: none; margin: 0; padding: 0; }
.hot-search li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px dashed var(--border); }
.hot-search li:last-child { border-bottom: 0; }
.hot-search .rk {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-mute); flex: none;
}
.hot-search li:nth-child(1) .rk { background: #ffe2db; color: var(--primary); }
.hot-search li:nth-child(2) .rk { background: #fff0e0; color: #ff8a3d; }
.hot-search li:nth-child(3) .rk { background: #fff7e0; color: #d99b1c; }
.hot-search .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.hot-search .heat { font-size: 11px; color: var(--text-mute); flex: none; }

/* ---------------- 主内容区 ---------------- */
.view { min-height: 60vh; }
.breadcrumb { font-size: 12.5px; color: var(--text-mute); margin: 4px 2px 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }

.section { margin-bottom: 26px; }
.section-head {
  display: flex; align-items: center; gap: 12px; margin: 0 2px 12px;
}
.section-head h2 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-head .bar { width: 4px; height: 18px; border-radius: 3px; background: var(--primary); }
.section-head .more { margin-left: auto; font-size: 13px; color: var(--text-mute); }
.section-head .more:hover { color: var(--primary); }

/* 排序切换 */
.sort-tabs { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 999px; }
.sort-tabs button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; color: var(--text-soft); font-weight: 600; transition: .2s;
}
.sort-tabs button.active { background: #fff; color: var(--primary-d); box-shadow: var(--shadow); }

/* ---------------- 卡片网格（v40 统一尺寸核心） ---------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);  /* 桌面 5 列 */
  gap: 14px;
}
/* 中间区卡片：宽高完全固定，内容再多也不撑开 */
.card {
  height: var(--card-h);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-h); border-color: var(--primary); }
.card .fav {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--surface-2); display: grid; place-items: center;
  font-weight: 700; color: var(--primary); font-size: 15px; overflow: hidden;
}
.card .fav img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
.card .body { min-width: 0; flex: 1; }
.card .name { font-weight: 700; font-size: 14px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .desc {
  font-size: 12px; color: var(--text-mute); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 方形卡片：热门榜（图标在上、名称在下），大小完全一致，保持原样 */
.card-grid .card {
  height: auto;
  aspect-ratio: 1 / 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 10px 8px;
}
.card-grid .card .fav {
  width: 46px; height: 46px; margin: 0; border-radius: 12px;
}
.card-grid .card .fav img { border-radius: 12px; }
.card-grid .card .body { width: 100%; flex: none; text-align: center; }
.card-grid .card .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-grid .card .desc {
  -webkit-line-clamp: 1;
  margin-top: 4px;
  font-size: 11px;
  text-align: center;
}

/* 小长方体卡片：分类/搜索等区块（图标在左、文字在右），大小一致、单行不换行、省略号 */
.cat-grid .card {
  height: 60px;
  aspect-ratio: auto;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 10px;
  padding: 0 12px;
}
.cat-grid .card .fav {
  width: 32px; height: 32px; margin: 0; border-radius: 8px;
}
.cat-grid .card .fav img { border-radius: 8px; }
.cat-grid .card .body { width: auto; flex: 1; min-width: 0; text-align: left; }
.cat-grid .card .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.cat-grid .card .desc { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; font-size: 11px; text-align: left; }

/* 骨架屏 */
.card.skeleton { pointer-events: none; }
.card.skeleton .fav, .card.skeleton .sk-line { background: linear-gradient(90deg,#eef1f6 25%,#e3e8f0 37%,#eef1f6 63%); background-size: 400% 100%; animation: sh 1.2s infinite; }
.card.skeleton .body { flex:1; }
.card.skeleton .sk-line { height: 10px; border-radius: 5px; margin-bottom: 7px; }
.card.skeleton .sk-line.short { width: 50%; }
@keyframes sh { 0%{background-position:100% 0} 100%{background-position:-100% 0} }

/* ---------------- 详情页 ---------------- */
.detail-hero {
  background: linear-gradient(135deg, #fff, var(--primary-soft));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; display: flex; gap: 20px; align-items: center; box-shadow: var(--shadow);
}
.detail-hero .fav-big {
  width: 72px; height: 72px; border-radius: 16px; flex: none;
  background: #fff; display: grid; place-items: center; font-size: 30px; font-weight: 800; color: var(--primary);
  box-shadow: var(--shadow); overflow: hidden;
}
.detail-hero .fav-big img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.detail-hero h1 { margin: 0 0 6px; font-size: 22px; }
.detail-hero .url-line { color: var(--text-mute); font-size: 13px; word-break: break-all; }
.detail-hero .desc { margin: 10px 0 0; color: var(--text-soft); }
.detail-actions { margin-top: 14px; display: flex; gap: 10px; }

.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin: 18px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat .num { font-size: 24px; font-weight: 800; color: var(--primary-d); }
.stat .lbl { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

.tags-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.tags-row a { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); }
.tags-row a:hover { background: var(--primary-soft); color: var(--primary-d); }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-mute); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
/* 分类区块内“暂无网址”：横跨整行、矮一些，与其它区块对齐 */
.card-grid .empty-cat { grid-column: 1 / -1; padding: 8px 4px; color: var(--text-mute); font-size: 13px; }

/* 分页 */
.pager { display: flex; justify-content: center; gap: 8px; margin: 22px 0; }
.pager button {
  min-width: 36px; height: 36px; border: 1px solid var(--border); background: #fff;
  border-radius: 9px; font-size: 13px; color: var(--text-soft); transition: .15s;
}
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* tooltip */
#tooltip {
  position: fixed; z-index: 200; pointer-events: none; max-width: 260px;
  background: #1f2733; color: #fff; font-size: 12.5px; line-height: 1.5;
  padding: 9px 12px; border-radius: 8px; box-shadow: var(--shadow-h);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
#tooltip.show { opacity: 1; transform: translateY(0); }
#tooltip b { color: #ffb38a; }

/* 返回顶部 */
#toTop {
  position: fixed; right: 26px; bottom: 30px; width: 44px; height: 44px;
  border-radius: 50%; background: var(--primary); color: #fff; border: 0;
  box-shadow: var(--shadow-h); font-size: 20px; opacity: 0; pointer-events: none;
  transform: translateY(10px); transition: .25s; z-index: 60;
}
#toTop.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
#toTop:hover { background: var(--primary-d); }

/* 消息提示 */
#toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%) translateY(-20px);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; transition: .25s; z-index: 300; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Footer ---------------- */
.footer {
  border-top: 1px solid var(--border); background: var(--surface);
  margin-top: 30px;
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 22px 20px; text-align: center; color: var(--text-mute); font-size: 13px; }
.footer-inner a { color: var(--primary); margin: 0 6px; }
.footer-inner .links { margin-bottom: 8px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 200px minmax(0,1fr); }
  .sidebar.right { display: none; }
  .card-grid { grid-template-columns: repeat(4, 1fr); }  /* 中屏 4 列 */
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 14px; }
  .sidebar.left { position: static; }
  .sidebar.right { display: block; }  /* 手机端：右栏内容显示在主内容下方 */
  .cat-list { max-height: none; display: flex; flex-wrap: wrap; gap: 8px; }
  .cat-list li { margin: 0; }
  .cat-list a { padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; }
  .cat-list a .num { display: none; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .search .kbd { display: none; }
  .search input { padding: 0 16px 0 40px; }  /* kbd 隐藏后去掉右侧预留空间 */
  .header-actions .btn:not(.btn-primary) { display: none; }
  .header-inner { padding: 10px 14px; gap: 12px; }
  .logo { font-size: 16px; gap: 8px; }
  .logo .mark { width: 30px; height: 30px; font-size: 16px; }
  .logo small { display: none; }
  .layout { padding: 0 14px; margin: 12px auto; }
  .panel { padding: 12px; }
  .section { margin-bottom: 18px; }
  .section-head h2 { font-size: 15px; }
  .detail-hero { padding: 20px 16px; gap: 14px; }
  .detail-hero h1 { font-size: 19px; }
}
@media (max-width: 560px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { height: 80px; padding: 10px; }
  .card-grid .card .fav { width: 40px; height: 40px; }
  .card-grid .card .name { font-size: 12.5px; }
  .card-grid .card .desc { font-size: 11px; }
  .detail-hero { flex-direction: column; text-align: center; padding: 18px 14px; }
  .detail-hero .fav-big { width: 56px; height: 56px; font-size: 24px; border-radius: 14px; }
  .detail-hero h1 { font-size: 18px; }
  .stat-row { grid-template-columns: 1fr; }
  .header-inner { padding: 8px 12px; gap: 8px; }
  .logo { font-size: 15px; }
  .logo .mark { width: 28px; height: 28px; font-size: 14px; }
  .layout { padding: 0 10px; margin: 10px auto; }
  .footer-inner { padding: 16px 12px; font-size: 12px; }
  #toTop { right: 14px; bottom: 18px; width: 40px; height: 40px; font-size: 18px; }
  .pager button { min-width: 32px; height: 32px; font-size: 12px; }
  .pager { gap: 5px; }
  .stat .num { font-size: 20px; }
  .cat-list a { padding: 6px 10px; font-size: 13px; }
  .sort-tabs button { padding: 5px 10px; font-size: 12px; }
}

/* 网址可访问性检测结果（v-p） */
.chk-res { display: inline-block; margin-top: 4px; font-size: 11.5px; line-height: 1.4; color: var(--text-mute); word-break: break-all; max-width: 150px; }
.chk-res.ok { color: #1f9d57; }
.chk-res.bad { color: #c0392b; }

/* 后台表格：表头不折行（v-s），避免“分类 / 状态 / 访问耗时”等标题在窄列被换行 */
.ad th { white-space: nowrap; }
/* 访问耗时列内容也保持单行，避免 ✅0.32s·200 被折成两行 */
.ad td:nth-child(6) { white-space: nowrap; }
