:root {
  --page: #eef1f6;
  --page-accent: #cbdfff;
  --page-accent-alt: #e4cdf5;
  --surface: #ffffff;
  --surface-soft: #f5f6f9;
  --surface-hover: #f1f2f7;
  --line: #e3e6ed;
  --line-strong: #d1d5df;
  --ink: #1d1f2a;
  --ink-soft: #4b4f5e;
  --muted: #6f7583;
  --accent: #5948dc;
  --accent-soft: #eeebff;
  --accent-ink: #4d3bd1;
  --focus: #6655e8;
  --danger-overlay: rgba(17, 20, 29, 0.42);
  --shadow-shell: 0 24px 68px rgba(44, 55, 82, 0.14);
  --shadow-card: 0 5px 16px rgba(44, 55, 82, 0.045);
  --shadow-hover: 0 12px 24px rgba(44, 55, 82, 0.1);
  --radius-card: 16px;
  --max-width: 1560px;
  --search-width: 672px;
  --motion-fast: 160ms;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --page: #17191f;
  --page-accent: #263b61;
  --page-accent-alt: #422b52;
  --surface: #24262f;
  --surface-soft: #2b2e38;
  --surface-hover: #31343f;
  --line: #383b46;
  --line-strong: #4b4f5c;
  --ink: #f2f3f7;
  --ink-soft: #d1d3dc;
  --muted: #a9adba;
  --accent: #9a8cff;
  --accent-soft: #393451;
  --accent-ink: #c2b9ff;
  --focus: #b2a8ff;
  --danger-overlay: rgba(0, 0, 0, 0.64);
  --shadow-shell: 0 24px 68px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 5px 16px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 12px 24px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background:
    radial-gradient(circle at 8% 0%, var(--page-accent), transparent 30%),
    radial-gradient(circle at 96% 100%, var(--page-accent-alt), transparent 28%),
    var(--page);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.page-shell {
  width: min(var(--max-width), calc(100% - 48px));
  margin: 32px auto;
}

.hero {
  padding-bottom: 24px;
}

.search-section {
  display: grid;
  gap: 12px;
  width: min(var(--search-width), 100%);
  margin: 0 auto;
}

.search-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.engine-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.engine-pill,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition:
    transform var(--motion-fast) ease,
    color var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    background var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}

.engine-pill img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.engine-pill.is-active {
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.theme-switcher {
  flex: 0 0 auto;
}

.theme-toggle {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
}

.theme-toggle span {
  font-size: 16px;
}

.theme-toggle strong {
  font-size: 14px;
  font-weight: 750;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition:
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}

.search-form:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.search-form input {
  min-width: 0;
  padding: 0 18px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.search-form input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-form button {
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--accent);
  transition: background var(--motion-fast) ease;
}

.search-form button span {
  font-size: 30px;
  line-height: 1;
  transform: translateY(-1px);
}

.quick-section {
  margin-top: 24px;
}

.card-grid {
  display: grid;
  gap: 12px;
}

.quick-grid {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.nav-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 104px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  text-align: center;
  appearance: none;
  transition:
    transform var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    background var(--motion-fast) ease;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
}

.card-icon img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(35, 40, 55, 0.12));
}

.card-title {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.category-block {
  min-width: 0;
}

.category-panel {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.category-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  border: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-soft) 74%, var(--surface)), transparent 78%);
}

.category-mark {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.category-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
  padding: 9px 11px 12px;
}

.category-site {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 6px 7px;
  border-radius: 10px;
  color: var(--ink-soft);
  transition:
    color var(--motion-fast) ease,
    background var(--motion-fast) ease;
}

.category-site img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

body[data-theme="dark"] .card-icon img,
body[data-theme="dark"] .category-site img {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.42));
}

.category-site span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  padding: 26px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) {
  .site-footer a:hover {
    color: var(--ink-soft);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.note-modal {
  width: min(520px, calc(100% - 32px));
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-shell);
}

.note-modal::backdrop {
  background: var(--danger-overlay);
}

.note-modal h2 {
  margin: 0 48px 12px 0;
  font-size: 20px;
  line-height: 1.35;
}

.note-modal p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  white-space: pre-wrap;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  font-weight: 750;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition:
    transform var(--motion-fast) ease,
    opacity var(--motion-fast) ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 21px;
  font-weight: 850;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    transform var(--motion-fast) ease,
    opacity var(--motion-fast) ease,
    background var(--motion-fast) ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.nav-card:focus-visible,
.category-site:focus-visible,
.engine-pill:focus-visible,
.theme-toggle:focus-visible,
.search-form button:focus-visible,
.modal-close:focus-visible,
.back-to-top:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (hover: hover) {
  .engine-pill:hover,
  .theme-toggle:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-card);
    transform: translateY(-1px);
  }

  .theme-toggle:hover {
    border-color: transparent;
  }

  .search-form button:hover,
  .category-site:hover,
  .back-to-top:hover {
    background: var(--surface-hover);
  }

  .category-site:hover {
    color: var(--ink);
  }

  .nav-card:hover {
    border-color: var(--line-strong);
    background: var(--surface);
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
  }
}

@media (min-width: 960px) {
  .main-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1380px) {
  .main-content {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 959px) {
  .page-shell {
    width: min(100% - 24px, var(--max-width));
    margin: 12px auto;
  }

  .hero {
    padding-bottom: 18px;
  }

  .quick-section {
    margin-top: 18px;
  }

  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
  }

  .nav-card {
    min-height: 88px;
    padding: 9px 5px;
    border-radius: 13px;
  }

  .card-icon {
    width: 34px;
    height: 34px;
  }

  .card-icon img {
    width: 29px;
    height: 29px;
  }

  .category-panel {
    border-radius: 14px;
  }

  .category-site {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .category-site img {
    width: 22px;
    height: 22px;
  }

  .category-site span {
    font-size: 13px;
  }

  .back-to-top {
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 420px) {
  .page-shell {
    width: 100%;
    margin: 0;
    padding: 12px;
  }

  .search-toolbar,
  .engine-switch {
    gap: 6px;
  }

  .engine-pill {
    min-width: 60px;
    padding: 0 8px;
    gap: 5px;
    font-size: 12px;
  }

  .engine-pill img {
    width: 16px;
    height: 16px;
  }

  .theme-toggle {
    padding: 0 9px;
    gap: 5px;
  }

  .theme-toggle strong {
    font-size: 12px;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) 52px;
    min-height: 54px;
  }

  .quick-grid {
    gap: 7px;
  }

  .nav-card {
    min-height: 84px;
  }

  .card-title {
    font-size: 11px;
  }

  .category-grid {
    gap: 4px;
  }

  .category-site {
    grid-template-columns: 25px minmax(0, 1fr);
    gap: 6px;
    padding: 5px 4px;
  }

  .category-site img {
    width: 22px;
    height: 22px;
  }

  .category-site span {
    font-size: 12px;
  }

}

@media (hover: none) {
  .nav-card:active,
  .category-site:active,
  .engine-pill:active,
  .theme-toggle:active {
    background: var(--surface-hover);
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
