/* ==========================================================================
   NCP服务器 · 扩展样式
   无障碍 · 手机底部导航 · 骨架屏 · 文档 / 排行榜 / 搜索页
   只使用 tokens.css 中的变量，浅色 / 深色自动适配。
   ========================================================================== */

/* ---------------------------------------------------------------- 无障碍 */
.skip-link {
  position: fixed; left: 12px; top: -64px; z-index: 1000;
  padding: 10px 16px; border-radius: var(--r-md, 12px);
  background: var(--accent); color: #fff; font-weight: 600; text-decoration: none;
  transition: top .2s ease;
}
.skip-link:focus { top: 12px; outline: 3px solid var(--text); outline-offset: 2px; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
#view:focus { outline: none; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (prefers-contrast: more) {
  :root { --line: rgba(0, 0, 0, .35); --text-3: #55555a; }
  html[data-theme="dark"] { --line: rgba(255, 255, 255, .4); --text-3: #b0b0b6; }
}

/* ---------------------------------------------------------------- 手机底部导航 */
.tabbar { display: none; }
@media (max-width: 720px) {
  body.has-tabbar #app { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface-solid); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 48px; border-radius: 12px; text-decoration: none;
    color: var(--text-3); font-size: 11px; font-weight: 500;
  }
  .tabbar a .ti { width: 22px; height: 22px; display: block; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  /* 触摸目标不小于 44px */
  .btn, .icon-btn, .nav-link, .pill-btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
}

/* ---------------------------------------------------------------- 骨架屏 */
.sk-stack { display: grid; gap: 14px; padding: 8px 0 24px; }
.sk-line { height: 14px; border-radius: 8px; }
.sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; }
.sk-title { height: 30px; width: 46%; border-radius: 10px; }
.sk-card { height: 120px; border-radius: var(--r-lg, 20px); }
.sk-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------------------------------------------------------------- 通用小件 */
.xt-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; line-height: 1.5; text-decoration: none; cursor: pointer;
  background: var(--surface-hover); color: var(--text-2); border: 1px solid transparent;
}
a.xt-tag:hover, button.xt-tag:hover { background: var(--accent-soft); color: var(--accent); }
.xt-tag.on { background: var(--accent); color: #fff; }
.xt-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.xt-badge-admin { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.xt-badge-me { background: rgba(52, 199, 89, .15); color: #1f9c46; }
html[data-theme="dark"] .xt-badge-me { color: #4cd964; }
.xt-stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.xt-stat { padding: 16px 18px; border-radius: var(--r-lg, 20px); background: var(--surface); border: 1px solid var(--line); }
.xt-stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.xt-stat .l { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------------------------------------------------------------- 文档页 */
.xt-docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; margin-top: 24px; }
.xt-toc { position: sticky; top: 84px; display: grid; gap: 2px; padding: 8px; }
.xt-toc a { padding: 8px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 14px; }
.xt-toc a:hover { background: var(--surface-hover); }
.xt-toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.xt-doc-sec { scroll-margin-top: 84px; margin-bottom: 36px; }
.xt-doc-sec > h2 { font-size: 24px; letter-spacing: -.01em; margin: 0 0 6px; }
.xt-doc-sec > .sub { color: var(--text-2); margin: 0 0 16px; }
.xt-steps { counter-reset: s; display: grid; gap: 12px; list-style: none; padding: 0; margin: 0; }
.xt-steps li { counter-increment: s; position: relative; padding: 16px 18px 16px 62px; border-radius: var(--r-lg, 20px);
  background: var(--surface); border: 1px solid var(--line); }
.xt-steps li::before { content: counter(s); position: absolute; left: 18px; top: 16px; width: 30px; height: 30px;
  border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; }
.xt-steps b { display: block; margin-bottom: 2px; }
.xt-steps span { color: var(--text-2); font-size: 14px; }
.xt-addr { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.xt-addr code { font-size: 18px; padding: 8px 14px; border-radius: 12px; background: var(--surface-hover); user-select: all; }
.xt-faq details { border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px; background: var(--surface); margin-bottom: 8px; }
.xt-faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.xt-faq details p { margin: 0 0 14px; color: var(--text-2); line-height: 1.7; }
.xt-code { display: block; white-space: pre; overflow-x: auto; padding: 14px 16px; border-radius: 12px; background: var(--surface-hover);
  font-size: 12.5px; line-height: 1.6; }
@media (max-width: 860px) {
  .xt-docs { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .xt-docs > * { min-width: 0; }
  .xt-toc { position: sticky; top: 56px; z-index: 30; display: flex; overflow-x: auto; max-width: 100%; padding: 6px;
    background: var(--surface-solid); border: 1px solid var(--line); border-radius: 999px; scrollbar-width: none; }
  .xt-toc a { flex: none; white-space: nowrap; }
}

/* ---------------------------------------------------------------- 玩家 / 排行榜 */
.xt-online { display: flex; flex-wrap: wrap; gap: 10px; }
.xt-player { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.xt-player .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.xt-podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; margin: 20px 0 12px; }
.xt-podium .p { text-align: center; padding: 18px 10px 16px; border-radius: var(--r-lg, 20px); background: var(--surface); border: 1px solid var(--line); }
.xt-podium .p.r1 { padding-top: 28px; padding-bottom: 24px; border-color: var(--accent-line); box-shadow: var(--shadow-1); }
.xt-podium .medal { font-size: 26px; }
.xt-podium .name { font-weight: 600; margin-top: 6px; word-break: break-all; }
.xt-podium .val { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.xt-rank { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--line); }
.xt-rank:last-child { border-bottom: 0; }
.xt-rank.me { background: var(--accent-soft); border-radius: 12px; }
.xt-rank .no { text-align: center; color: var(--text-3); font-weight: 700; }
.xt-rank .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.xt-rank .who a { color: inherit; text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.xt-rank .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.xt-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.xt-tabs button { padding: 8px 16px; min-height: 40px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); cursor: pointer; }
.xt-tabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ---------------------------------------------------------------- 搜索页 */
.xt-search-box { display: flex; gap: 10px; margin-top: 20px; }
.xt-search-box input { flex: 1; min-height: 48px; padding: 0 18px; font-size: 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-solid); color: var(--text); }
.xt-search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.xt-result { display: block; padding: 16px 18px; border-radius: var(--r-lg, 20px); background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; color: inherit; transition: border-color .2s, transform .2s; }
.xt-result:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.xt-result .t { font-weight: 600; font-size: 16px; }
.xt-result .s { color: var(--text-2); font-size: 14px; margin: 4px 0 8px; line-height: 1.6; }
.xt-result mark { background: rgba(255, 204, 0, .35); color: inherit; border-radius: 3px; padding: 0 2px; }
.xt-kind { font-size: 11px; padding: 2px 8px; border-radius: 999px; margin-right: 8px; vertical-align: 2px; }
.xt-kind.resource { background: rgba(50, 173, 230, .16); color: var(--teal); }
.xt-kind.activity { background: rgba(255, 149, 0, .16); color: #c97400; }
.xt-kind.announcement { background: var(--accent-soft); color: var(--accent); }
.xt-list { display: grid; gap: 10px; margin-top: 16px; }

/* 导航里的搜索入口：手机上由底部导航承担，顶栏保持不拥挤 */
.nav .nav-search { display: inline-grid; place-items: center; }
.nav .brand, .nav .brand * { white-space: nowrap; }
@media (max-width: 720px) {
  .nav .nav-search { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .skip-link, .xt-result { transition: none; }
  .xt-result:hover { transform: none; }
}

/* 从通知跳转到分区时的短暂高亮 */
.zone.is-targeted { animation: xt-target 2.2s ease; border-radius: var(--r-lg, 20px); }
@keyframes xt-target { 0%, 60% { box-shadow: 0 0 0 3px var(--accent-line, var(--accent)); } 100% { box-shadow: 0 0 0 3px transparent; } }
@media (prefers-reduced-motion: reduce) { .zone.is-targeted { animation: none; outline: 2px solid var(--accent); } }
.zone { scroll-margin-top: 84px; }

/* 通用：从通知跳转到某个条目后的高亮 */
.is-targeted { animation: xt-target 2.4s ease; }

/* 通知中心分类标签 */
.notify-tabs { flex: none; display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.notify-tabs::-webkit-scrollbar { display: none; }
.notify-tabs button { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.notify-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.notify-tabs button i { font-style: normal; font-size: 11px; min-width: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.notify-tabs button.on i { background: rgba(255,255,255,.25); color: #fff; }

/* ---------------------------------------------------------------- 标签订阅选择器 */
.tag-sub-chosen .xt-tags { gap: 8px; }
.tag-sub-chip { font-weight: 600; padding-right: 6px; }
.tag-sub-x { border: 0; background: rgba(255, 255, 255, .22); color: inherit; cursor: pointer; border-radius: 999px; width: 16px; height: 16px; line-height: 1; font-size: 10px; display: inline-grid; place-items: center; margin-left: 4px; }
.tag-sub-x:hover { background: rgba(255, 255, 255, .38); }
.tag-sub-panel { border-top: 1px dashed var(--line-strong); padding-top: 14px; }
.tag-sub-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tag-sub-form { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; max-width: 480px; }
.tag-sub-field { position: relative; flex: 1 1 auto; display: block; }
.tag-sub-field::before { content: ''; position: absolute; left: 12px; top: 50%; width: 11px; height: 11px; margin-top: -7px; border: 1.8px solid var(--text-3); border-radius: 50%; pointer-events: none; }
.tag-sub-field::after { content: ''; position: absolute; left: 21px; top: 50%; width: 5px; height: 1.8px; margin-top: 3px; background: var(--text-3); transform: rotate(45deg); transform-origin: left center; pointer-events: none; }
.tag-sub-field .input { padding-left: 32px; }
.tag-sub-cloud { gap: 8px; max-height: 240px; overflow: auto; padding-right: 4px; }
.tag-sub-pick { cursor: pointer; border-color: var(--line); color: var(--text-2); background: var(--surface-hover); font: inherit; }
.tag-sub-pick:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tag-sub-num { font-size: 10.5px; opacity: .68; margin-left: 4px; }
.xt-tag.on .tag-sub-num { opacity: .8; }
