/* ============================================================
   Tools 引索
   视觉参考：Reddit（顶栏 + 左导航 + 信息流卡片 + 右侧栏）
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #dae0e6;
  --surface: #ffffff;
  --surface-2: #f6f7f8;
  --border: #cccccc;
  --text: #1a1a1b;
  --text-weak: #576f76;
  --link: #0079d3;
  --brand: #ff4500;
  --brand-hover: #d93a00;
  --radius-card: 4px;
  --radius-pill: 9999px;
  --header-h: 57px;
  --font: "IBM Plex Sans", "Noto Sans SC", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #030303;
  --surface: #1a1a1b;
  --surface-2: #272729;
  --border: #343536;
  --text: #d7dadc;
  --text-weak: #818384;
  --link: #4fbcff;
  --brand: #ff4500;
  --brand-hover: #ff581a;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  transition: background-color .2s ease, color .2s ease;
}

a { color: var(--link); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 60;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 8px 14px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------------- 载入页 ---------------- */

/* 载入期间锁住页面滚动，免得幕布边上露出滚动条 */
html.is-loading { overflow: hidden; }

.loading-box {
  position: fixed; inset: 0; z-index: 100;
  overflow: hidden;
  /* JS 万一没跑起来，这层也会自己消失，不会挡住页面 */
  animation: loading-fallback .5s ease 2.6s forwards;
}

.loading-half {
  position: absolute; top: 0; bottom: 0; width: 50.2%;
  background: var(--surface);
  transition: transform .62s cubic-bezier(.76, 0, .24, 1);
}
.loading-left { left: 0; }
.loading-right { right: 0; }

.loading-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
  transition: opacity .32s ease, transform .32s ease;
}

.loading-squares { display: flex; gap: 7px; }
.loading-square {
  width: 11px; height: 11px;
  background: var(--brand);
  animation: loading-pulse 1.05s ease-in-out infinite;
}
.loading-square:nth-child(2) { animation-delay: .14s; }
.loading-square:nth-child(3) { animation-delay: .28s; }
.loading-square:nth-child(4) { animation-delay: .42s; }

.loading-quote {
  margin: 0; max-width: 32ch;
  font-size: 15.5px; font-weight: 500; line-height: 1.6; color: var(--text);
}
.loading-brand {
  margin: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .6px;
  color: var(--text-weak);
}

.loading-box.is-done .loading-left { transform: translateX(-100%); }
.loading-box.is-done .loading-right { transform: translateX(100%); }
.loading-box.is-done .loading-center { opacity: 0; transform: translateY(-8px); }

@keyframes loading-pulse {
  0%, 100% { opacity: .22; transform: scale(.72); }
  50%      { opacity: 1; transform: scale(1); }
}
@keyframes loading-fallback {
  to { opacity: 0; visibility: hidden; }
}

/* ---------------- 顶栏 ---------------- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background-color .2s ease, border-color .2s ease;
}

.header-inner {
  max-width: 1400px; margin: 0 auto;
  height: 56px; padding: 0 16px;
  display: flex; align-items: center; gap: 16px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none; flex: none;
}

.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }

.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  flex: 1 1 420px; max-width: 620px; margin: 0 auto;
  height: 40px; padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.search:hover { border-color: var(--border); }
.search:focus-within {
  background: var(--surface);
  border-color: var(--link);
  box-shadow: 0 0 0 3px hsl(203 100% 41% / .16);
}
.search-icon { width: 17px; height: 17px; fill: var(--text-weak); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 14px; outline: none;
}
.search input::placeholder { color: var(--text-weak); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none; width: 20px; height: 20px; line-height: 1;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 50%;
  color: var(--text-weak); font-size: 16px; cursor: pointer;
}
.search-clear:hover { background: var(--border); color: var(--text); }
.search-clear[hidden] { display: none; }

.header-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 50%;
  color: var(--text-weak); cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn .icon-sun { display: none; }
[data-theme="dark"] .icon-btn .icon-sun { display: block; }
[data-theme="dark"] .icon-btn .icon-moon { display: none; }


/* ---------------- 三栏布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 756px) 312px;
  gap: 24px;
  justify-content: center;
  align-items: start;
  max-width: 1360px;
  margin: 20px auto 0;
  padding: 0 16px;
}

/* ---------------- 左侧导航 ---------------- */

.nav, .rail {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px 10px;
  margin-bottom: 16px;
  transition: background-color .2s ease, border-color .2s ease;
}

.nav-title {
  margin: 2px 0 8px; padding: 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-weak);
}

.nav-list { list-style: none; margin: 0 0 14px; padding: 0; }
.nav-list:last-child { margin-bottom: 0; }



.nav-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; margin-bottom: 2px;
  background: transparent; border: 0; border-radius: var(--radius-pill);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
  text-align: left; cursor: pointer;
  transition: background-color .12s ease;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-active { background: var(--surface-2); font-weight: 800; }
.nav-item .count { color: var(--text-weak); font-size: 12px; font-variant-numeric: tabular-nums; }
.nav-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-tip .nav-desc {
  margin: 0; padding: 0 10px 4px;
  font-size: 12.5px; line-height: 1.7; color: var(--text-weak);
}

/* 警告说明卡 */
.nav-warn {
  background: hsl(38 92% 50% / .08);
  border-color: hsl(38 82% 45% / .45);
  border-left: 3px solid hsl(38 85% 48%);
}
.nav-warn .nav-title {
  display: flex; align-items: center; gap: 6px;
  color: hsl(28 82% 36%);
}
.nav-warn .nav-title svg { width: 14px; height: 14px; fill: currentColor; flex: none; }
.nav-warn .nav-desc { color: hsl(28 45% 30%); }
[data-theme="dark"] .nav-warn { background: hsl(38 92% 50% / .10); border-color: hsl(38 80% 55% / .45); }
[data-theme="dark"] .nav-warn .nav-title { color: hsl(38 92% 64%); }
[data-theme="dark"] .nav-warn .nav-desc { color: hsl(40 40% 78%); }
[data-theme="dark"] .mirror-note { color: hsl(38 92% 64%); }

/* ---------------- 工具流 ---------------- */

.feed-toolbar {
  position: sticky; top: calc(var(--header-h) + 8px); z-index: 10;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 10px 14px; margin-bottom: 10px;
  transition: background-color .2s ease, border-color .2s ease;
}
.result-count { margin: 0; font-size: 13px; color: var(--text-weak); }
.result-count b { color: var(--text); font-weight: 700; }
.active-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 10px;
  background: hsl(var(--tag-hue, 203) 72% 34% / .10);
  border: 1px solid hsl(var(--tag-hue, 203) 72% 34% / .28);
  border-radius: var(--radius-pill);
  color: hsl(var(--tag-hue, 203) 72% 34%);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.chip:hover { background: hsl(var(--tag-hue, 203) 72% 34% / .18); }
.chip .chip-x { font-size: 14px; line-height: 1; opacity: .8; }

.link-btn {
  margin-left: auto;
  background: none; border: 0; border-radius: var(--radius-pill);
  padding: 4px 8px; color: var(--link);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.feed { display: flex; flex-direction: column; gap: 10px; }

/* ---------------- 工具卡片（Reddit 信息流结构） ---------------- */

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 11px 16px 12px;
  transition: background-color .2s ease, border-color .15s ease;
}
.tool-card:hover { border-color: hsl(203 100% 41% / .55); }

.card-main { min-width: 0; }

.title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-icon {
  flex: none; width: 24px; height: 24px;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
}
.title-img { width: 16px; height: 16px; object-fit: contain; }

.tool-title {
  margin: 0; min-width: 0;
  font-size: 16px; font-weight: 500; line-height: 1.35;
  overflow-wrap: anywhere;
}
.tool-title a { color: inherit; text-decoration: none; }
.tool-title a:hover { color: var(--link); text-decoration: underline; }

.ver-badge {
  flex: none; margin-left: auto;
  padding: 1px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-weak); font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  cursor: help;
}

.tool-desc {
  margin: 4px 0 0; padding-left: 32px;
  font-size: 13px; line-height: 1.5; color: var(--text-weak);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex; align-items: center; gap: 5px 8px; flex-wrap: wrap;
  margin-top: 7px; padding-left: 32px; min-width: 0;
}

.flair {
  padding: 1px 9px;
  background: hsl(var(--tag-hue, 203) 72% 38%);
  border-radius: var(--radius-pill);
  color: #fff; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
[data-theme="dark"] .flair { background: hsl(var(--tag-hue, 203) 55% 30%); color: #f2f4f5; }

.official-link {
  display: inline-flex; align-items: center; gap: 5px;
  min-width: 0; max-width: 100%;
  color: var(--text-weak); font-size: 12.5px; text-decoration: none;
}
.official-link svg { width: 13px; height: 13px; fill: currentColor; flex: none; }
.official-link:hover { color: var(--link); text-decoration: underline; }
.official-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.alt-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 9px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  color: var(--text-weak); font-size: 11.5px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.alt-link:hover { color: var(--link); border-color: var(--link); }



/* ---------------- 镜像站 / 软件源（独立列表，不混进工具流） ---------------- */

.mirror-block { margin-top: 22px; scroll-margin-top: calc(var(--header-h) + 12px); }
.feed-col > .mirror-block:first-child { margin-top: 0; }

.block-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 0 2px 8px; }
.block-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.block-head p { margin: 0; font-size: 12.5px; color: var(--text-weak); }

.mirror-list {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 8px;
}
.mirror-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: inherit; text-decoration: none;
  transition: background-color .12s ease;
}
.mirror-row:hover { background: var(--surface-2); }
.mirror-icon {
  flex: none; width: 28px; height: 28px;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
}
.mirror-img { width: 18px; height: 18px; object-fit: contain; }
.mirror-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mirror-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mirror-domain { font-size: 12px; color: var(--text-weak); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mirror-desc {
  margin-top: 1px; font-size: 12px; line-height: 1.4; color: var(--text-weak);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mirror-note {
  margin-top: 2px; font-size: 11px; line-height: 1.45;
  color: hsl(28 82% 36%);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mirror-note svg { width: 11px; height: 11px; margin-right: 4px; vertical-align: -1px; fill: currentColor; }
.mirror-tags { flex: none; display: flex; gap: 4px; }
.mirror-go { flex: none; width: 16px; height: 16px; }
.mirror-go svg { width: 16px; height: 16px; fill: var(--text-weak); }
.mirror-row:hover .mirror-go svg { fill: var(--link); }
.mirror-empty { margin: 0; padding: 12px; font-size: 13px; color: var(--text-weak); }
/* 空状态 */
.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 40px 20px; text-align: center; color: var(--text-weak);
}
.empty p { margin: 0 0 6px; }
.empty b { color: var(--text); }

/* ---------------- 右侧栏 ---------------- */

.rail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px; margin-bottom: 16px;
  transition: background-color .2s ease, border-color .2s ease;
}
.rail-head {
  margin: 0 0 10px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
  color: var(--text-weak);
}
.rail-desc { margin: 0; font-size: 13.5px; line-height: 1.7; }

/* -------- 右栏：ISO 镜像指向 -------- */

.iso-hint { margin: 0 0 10px; font-size: 12px; line-height: 1.6; color: var(--text-weak); }

.iso-group + .iso-group { margin-top: 10px; }
.iso-group-name {
  margin: 0 0 3px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  color: var(--text-weak);
}

.iso-list { list-style: none; margin: 0; padding: 0; }

.iso-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin: 0 -6px; padding: 3px 6px;
  border-radius: 6px;
  color: var(--text); font-size: 13px; line-height: 1.4; text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.iso-row:hover { background: var(--surface-2); color: var(--link); }
.iso-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iso-go { flex: none; width: 14px; height: 14px; display: grid; place-items: center; }
.iso-go svg { width: 14px; height: 14px; fill: var(--text-weak); }
.iso-row:hover .iso-go svg { fill: var(--link); }

.rule-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; font-size: 13px; }
.rule-list li { display: block; }
.rule-list b { font-weight: 700; margin-right: 4px; }

code {
  padding: 1px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono); font-size: 12px;
}

/* ---------------- 页脚 ---------------- */

.site-footer {
  margin-top: 20px; padding: 14px 4px 28px;
  color: var(--text-weak); font-size: 12.5px; line-height: 1.7;
}
.site-footer p { margin: 0 0 6px; }
.site-footer .muted { opacity: .85; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1200px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .rail { display: none; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .feed-toolbar { position: static; }
}

@media (max-width: 560px) {
  .brand { display: none; }
  .header-inner { gap: 10px; }
  .card-meta, .tool-desc { padding-left: 0; }
}

@media (max-width: 760px) {
  .mirror-list { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .loading-square { animation: none; opacity: 1; }
  .loading-box { animation-duration: .01s; animation-delay: 1.2s; }
}