:root {
  --bg: #101416;
  --surface: #171d20;
  --surface-raised: #1d2529;
  --surface-hover: #243035;
  --text: #eef4f2;
  --muted: #9eaeaa;
  --faint: #71817e;
  --line: #2b393d;
  --accent: #62ddd0;
  --accent-strong: #b1f3e9;
  --warm: #f0b66c;
  --danger: #f38d87;
  --shadow: rgb(0 0 0 / 22%);
}

[data-theme='light'] {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --surface-raised: #f0f5f3;
  --surface-hover: #e6efec;
  --text: #17211f;
  --muted: #5e706a;
  --faint: #82908c;
  --line: #d4e0dc;
  --accent: #087e72;
  --accent-strong: #075e56;
  --warm: #a45d13;
  --danger: #b14c48;
  --shadow: rgb(35 64 58 / 10%);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a { color: inherit; }

button, input, select { font: inherit; }

button, a, select { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-shell { width: min(1320px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  gap: 24px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
}

.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 15px; letter-spacing: .02em; }
.brand-copy small { color: var(--muted); font-size: 11px; }

.header-actions { display: flex; align-items: center; gap: 16px; }
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--accent-strong); }

.icon-button, .clear-search {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button { width: 34px; height: 34px; border-radius: 50%; }
.icon-button:hover, .clear-search:hover { border-color: var(--accent); color: var(--accent-strong); }

main { padding: 42px 0 72px; }

.catalog-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .16em; }
h2, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 19px; line-height: 1.2; }
#catalog-title { font-size: 24px; }

.tool-search-hero {
  position: relative;
  width: calc(100% + 40px);
  margin: -74px -20px 20px;
  padding: 80px 15px 110px;
  background-color: #1b1d1f;
  background-image: url('../../assets/images/bg-dna.jpg');
  background-position: center;
  background-size: cover;
  color: #fff;
  overflow: hidden;
}

.tool-search-hero::after {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 12%);
  content: '';
  pointer-events: none;
}

.tool-hero-search {
  position: relative;
  z-index: 1;
  width: min(800px, calc(100% - 30px));
  margin: 0 auto;
}

.tool-hero-main-list,
.tool-hero-channel-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.tool-hero-main-list {
  position: relative;
}

.tool-hero-main-list::-webkit-scrollbar,
.tool-hero-channel-list::-webkit-scrollbar { display: none; }

.tool-hero-main-list { min-height: 45px; }

.tool-hero-tab {
  position: relative;
  flex: 0 0 auto;
  border: 0;
  padding: 10px 20px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 31px;
  opacity: .5;
  transition: opacity .3s ease, color .3s ease;
}

.tool-hero-tab:hover,
.tool-hero-tab[aria-selected='true'] {
  color: #fff;
  opacity: 1;
}

.tool-hero-tab[aria-selected='true']::before {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 8px solid transparent;
  border-bottom: 0;
  border-left: 8px solid transparent;
  border-top: 8px solid rgb(255 255 255 / 82%);
  content: '';
  transform: translateX(-50%);
}

.tool-hero-anchor {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 10px;
  height: 4px;
  border-radius: 100px;
  background: #fff;
  pointer-events: none;
  transition: .25s;
}

.tool-hero-tab:not([aria-selected='true'])::after {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  content: '';
  transform: translateX(-50%);
  transition: background .3s ease;
}

.tool-hero-tab:hover::after { background: #fff; }

.tool-hero-form { position: relative; margin: 0 auto; }

.tool-hero-form input {
  width: 100%;
  height: 50px;
  padding: 9px 94px 9px 20px;
  border: 1px solid rgb(255 255 255 / 5%);
  border-radius: 50px;
  outline: 0;
  background: rgb(255 255 255 / 88%);
  color: #6c757d;
  font-size: 16px;
  backdrop-filter: blur(5px);
  transition: background .3s ease, border-color .3s ease;
}

.tool-hero-form input::placeholder { color: #6c757d; }
.tool-hero-form input:focus { border-color: rgb(255 255 255 / 46%); background: #fff; }

.tool-hero-form .clear-search,
.tool-hero-submit {
  position: absolute;
  top: 0;
  height: 50px;
  border: 0;
  background: transparent;
  color: #6c757d;
  cursor: pointer;
  line-height: 50px;
}

.tool-hero-form .clear-search {
  right: 46px;
  width: 30px;
  padding: 0;
  font-size: 19px;
}

.tool-hero-form .clear-search[hidden] { display: none; }

.tool-hero-submit {
  right: 9px;
  width: 32px;
  padding: 0;
  color: #6c757d;
  font-size: 24px;
}

.tool-hero-submit .iconfont { font-size: 18px; }

.tool-hero-submit:hover,
.tool-hero-form .clear-search:hover { color: #212529; }

.tool-hero-channel-list {
  min-height: 40px;
  margin-top: 8px;
}

.tool-hero-channel-list[hidden] { display: none; }

.tool-hero-channel-list .tool-hero-tab {
  padding: 2px 20px 5px;
  font-size: 14px;
  line-height: 31px;
}

.tool-hero-channel-list .tool-hero-tab[aria-selected='true']::before { display: block; }

/* 搜索区广告与首页搜索区一致：桌面端居中 728x90，手机端隐藏。 */
.search-top-ad {
  display: none;
  max-width: 728px;
  margin: 20px auto;
  text-align: center;
}

.search-top-ad .adsbygoogle {
  display: inline-block;
  width: 728px;
  height: 90px;
}

@media (min-width: 768px) {
  .search-top-ad { display: block; }
}

@media (orientation: portrait) and (min-width: 700px) and (max-width: 1100px) {
  .search-top-ad { display: block !important; }
}

[data-theme='dark'] .tool-search-hero .tool-hero-form input {
  border-color: #405156;
  background: rgb(29 37 41 / 92%);
  color: #f4f8f6;
}

[data-theme='dark'] .tool-search-hero .tool-hero-form input::placeholder,
[data-theme='dark'] .tool-search-hero .tool-hero-form .clear-search,
[data-theme='dark'] .tool-search-hero .tool-hero-submit { color: #9aaba6; }

[data-theme='dark'] .tool-search-hero::after { background: rgb(10 15 18 / 55%); }

[data-theme='dark'] .tool-search-hero .tool-hero-form input:focus {
  border-color: #62ddd0;
  background: #1d2529;
}

[data-theme='dark'] .tool-search-hero .tool-hero-submit:hover,
[data-theme='dark'] .tool-search-hero .tool-hero-form .clear-search:hover { color: #ffffff; }

.search-box { position: relative; display: flex; align-items: center; }
.search-prefix { position: absolute; left: 18px; color: var(--accent); font-family: ui-monospace, monospace; font-weight: 700; }
.search-box input {
  width: 100%;
  min-height: 54px;
  padding: 0 52px 0 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  box-shadow: 0 12px 30px var(--shadow);
}
.search-box input::placeholder { color: var(--faint); }
.search-box input:focus { border-color: var(--accent); outline: none; }
.clear-search { position: absolute; right: 12px; width: 30px; height: 30px; border-radius: 50%; font-size: 19px; line-height: 1; }
.catalog-section { padding-top: 12px; }

.catalog-toolbar { margin-bottom: 20px; align-items: center; }
.legacy-filter { position: relative; display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 16px; }
.legacy-filter::after { position: absolute; top: 50%; right: 8px; color: var(--muted); content: '\25BE'; font-size: 16px; line-height: 1; pointer-events: none; transform: translateY(-50%); }
.legacy-filter select { width: 110px; min-width: 110px; padding: 5px 25px 5px 8px; border: 1px solid var(--line); border-radius: 4px; appearance: none; background: var(--surface); color: var(--text); font-size: 16px; line-height: 1.4; }
.tools-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tool-card { display: flex; height: 106px; min-height: 106px; flex-direction: column; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.tool-card:hover { border-color: var(--accent); background: var(--surface-raised); transform: translateY(-2px); }
[data-theme='dark'] .tool-card { border-color: #405156; background: #1d2529; box-shadow: 0 2px 8px rgb(0 0 0 / 24%); color: #eef4f2; }
[data-theme='dark'] .tool-card:hover { border-color: #62ddd0; background: #243035; box-shadow: 0 4px 12px rgb(0 0 0 / 30%); }
.tool-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.tool-title-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tool-icon { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border: 1px solid var(--line); color: var(--accent-strong); font-size: 16px; }
[data-theme='dark'] .tool-icon { border-color: #496166; background: #243035; color: #b1f3e9; }
.tool-card h3 { overflow: hidden; margin: 0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.favorite-button { width: 28px; height: 28px; flex: 0 0 28px; border: 0; background: transparent; color: var(--faint); cursor: pointer; font-size: 17px; }
[data-theme='dark'] .tool-card h3 { color: #f4f8f6; }
[data-theme='dark'] .tool-card .tool-description { color: #b8c7c2; }
[data-theme='dark'] .tool-card .favorite-button { color: #9aaba6; }
.favorite-button:hover, .favorite-button[aria-pressed='true'] { color: var(--warm); }
.tool-description { display: -webkit-box; height: 36px; overflow: hidden; margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 18px; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
[data-theme='dark'] .tool-card:focus-visible { border-color: #62ddd0; outline: 2px solid #62ddd0; outline-offset: 2px; }
[data-theme='dark'] .catalog-toolbar h2 { color: #f4f8f6; }
[data-theme='dark'] .legacy-filter { color: #b8c7c2; }
[data-theme='dark'] .legacy-filter::after { color: #b8c7c2; }
[data-theme='dark'] .legacy-filter select { border-color: #405156; background: #1d2529; color: #f4f8f6; }
[data-theme='dark'] .site-footer { color: #71817e; }
[data-theme='dark'] .site-footer p { color: #9eaeaa !important; }
[data-theme='dark'] .site-footer a { color: #b8c7c2 !important; }
.empty-state { padding: 46px 20px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 15px; }
.empty-state p { margin: 0; font-size: 12px; }
.load-more { display: block; min-width: 160px; margin: 24px auto 0; padding: 10px 18px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--accent-strong); cursor: pointer; }
.load-more:hover { border-color: var(--accent); background: var(--surface-hover); }

.site-footer { display: grid; gap: 5px; padding: 20px 0 32px; color: var(--faint); font-size: 11px; text-align: center; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent-strong); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .site-shell { width: min(100% - 28px, 560px); }
  .site-header { min-height: 68px; }
  .back-link { display: none; }
  main { padding-top: 30px; }
  .tool-search-hero { width: calc(100% + 28px); margin: -74px -14px 15px; padding: 74px 0 45px; }
  .tool-hero-main-list,
  .tool-hero-channel-list { justify-content: flex-start; }
  .tool-hero-tab { padding-right: 16px; padding-left: 16px; }
  .tool-hero-channel-list .tool-hero-tab { padding-right: 16px; padding-left: 16px; }
  h1 { font-size: 30px; }
  .catalog-toolbar { align-items: center; flex-direction: row; gap: 12px; }
  .catalog-toolbar > div { min-width: 0; }
  #catalog-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .legacy-filter { width: 110px; flex: 0 0 110px; justify-content: flex-end; }
  .legacy-filter select { flex: 0 0 110px; }
  .tools-grid { grid-template-columns: minmax(0, 1fr); }
  .tool-card { height: 106px; min-height: 106px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
