:root {
  --bg: #f9fafb;
  --panel: #edf0f5;
  --surface: #ffffff;
  --surface-hover: #f6f8fc;
  --ink: #15191f;
  --muted: #4a5568;
  --subtle: #7b8491;
  --line: #e3e7ee;
  --line-strong: #cfd6e2;
  --primary: #2563eb;
  --primary-dark: #174fca;
  --primary-soft: #e8efff;
  --secondary: #6275af;
  --secondary-soft: #eef2fb;
  --tertiary: #bc4800;
  --tertiary-soft: #fff1e8;
  --shadow: 0 16px 36px rgba(21, 25, 31, 0.12);
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(37, 99, 235, 0.018) 28%, transparent 48%),
    repeating-linear-gradient(0deg, rgba(98, 117, 175, 0.05) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(90deg, rgba(98, 117, 175, 0.045) 0 1px, transparent 1px 36px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

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

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid #dce2eb;
  background: rgba(237, 240, 245, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 18px 14px;
}

.sidebar-header {
  margin-bottom: 22px;
  padding: 0 2px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26), 0 8px 18px rgba(37, 99, 235, 0.16);
  transition:
    box-shadow 220ms var(--ease),
    transform 220ms var(--ease);
}

.brand:hover .logo-mark,
.mobile-brand:hover .logo-mark {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 10px 22px rgba(37, 99, 235, 0.22);
  transform: translateY(-1px);
}

.brand-text strong,
.brand-text small {
  display: block;
}

.brand-text strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-text small {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 600;
}

.sidebar-nav {
  min-width: 0;
}

.filter-list {
  display: grid;
  gap: 4px;
}

.filter-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  width: 100%;
  border-radius: 0;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 700;
  padding: 0 14px;
  text-align: left;
  text-transform: uppercase;
  transition:
    background 180ms var(--ease),
    color 180ms var(--ease),
    transform 180ms var(--ease);
}

.filter-chip span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  transform: translateX(2px);
}

.filter-chip.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.06);
  transform: none;
}

.filter-chip.active span {
  color: var(--tertiary);
}

.app-main {
  position: relative;
  min-width: 0;
  padding: 28px clamp(28px, 4vw, 60px) 56px;
}

.main-header {
  display: grid;
  gap: 6px;
  margin-bottom: 28px;
  animation: soft-rise 520ms var(--ease) both;
}

.mobile-brand {
  display: none;
}

.main-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0;
}

.main-subtitle {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.results-panel {
  display: grid;
  gap: 16px;
  animation: fade-in 520ms var(--ease) 80ms both;
}

.result-summary {
  display: inline-flex;
  justify-self: start;
  align-items: center;
  min-height: 24px;
  background: var(--tertiary-soft);
  color: var(--tertiary);
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.tool-row {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 148px;
  border: 1px solid transparent;
  background: var(--surface);
  overflow: hidden;
  padding: 20px;
  cursor: pointer;
  outline: 0;
  animation: card-in 480ms var(--ease) both;
  transition:
    border-color 220ms var(--ease),
    background 220ms var(--ease),
    box-shadow 220ms var(--ease),
    transform 220ms var(--ease);
}

.tool-row::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary), transparent);
  opacity: 0;
  transform: translateX(-24px);
  transition:
    opacity 220ms var(--ease),
    transform 220ms var(--ease);
}

.tool-row:nth-child(2n) {
  animation-delay: 35ms;
}

.tool-row:nth-child(3n) {
  animation-delay: 70ms;
}

.tool-row:nth-child(4n) {
  animation-delay: 105ms;
}

.tool-row:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
  transform: translateY(-3px);
}

.tool-row:hover::before {
  opacity: 1;
  transform: translateX(0);
}

.tool-row:focus-visible,
.mobile-tool-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.tool-row h3 {
  margin: 0 0 12px;
  color: #252b34;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.tool-summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
}

.tool-meta span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  flex: 0 0 auto;
  color: var(--primary);
  opacity: 0.82;
  transition:
    opacity 180ms var(--ease),
    transform 180ms var(--ease);
}

.tool-row:hover .card-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.mobile-groups {
  display: none;
}

.tool-dialog {
  width: min(680px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.tool-dialog::backdrop {
  background: rgba(21, 25, 31, 0.46);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dialog-body {
  position: relative;
  max-height: min(82vh, 760px);
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  padding: 30px;
  box-shadow: var(--shadow);
  animation: dialog-in 220ms var(--ease) both;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 8px;
  background: #f1f3f4;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  transition:
    background 180ms var(--ease),
    color 180ms var(--ease),
    transform 180ms var(--ease);
}

.dialog-close:hover {
  background: #e7ebf2;
  color: var(--ink);
  transform: scale(1.03);
}

.dialog-head {
  padding-right: 44px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.dialog-head h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.22;
  letter-spacing: 0;
}

.dialog-head p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.dialog-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.dialog-section h3 {
  margin: 0 0 8px;
  color: #252b34;
  font-size: 15px;
  font-weight: 700;
}

.dialog-section p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.dialog-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
}

.primary-link {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 0 18px;
  transition:
    background 180ms var(--ease),
    box-shadow 180ms var(--ease),
    transform 180ms var(--ease);
}

.primary-link:hover {
  background: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
  transform: translateY(-1px);
}

.access-note {
  display: inline-block;
  margin: 0;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 32px;
  text-align: center;
}

.site-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 56px;
  border-top: 1px solid var(--line);
  color: var(--subtle);
  font-size: 12px;
  padding-top: 18px;
  animation: fade-in 520ms var(--ease) 120ms both;
}

.site-footer div,
.site-footer p {
  margin: 0;
}

.site-footer div {
  display: grid;
  gap: 3px;
}

.site-footer strong {
  color: var(--ink);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filter-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    background-color: var(--bg);
    background-image:
      linear-gradient(135deg, rgba(37, 99, 235, 0.06), transparent 46%),
      repeating-linear-gradient(0deg, rgba(98, 117, 175, 0.045) 0 1px, transparent 1px 32px),
      repeating-linear-gradient(90deg, rgba(98, 117, 175, 0.04) 0 1px, transparent 1px 32px);
  }

  .app-layout {
    display: block;
  }

  .app-sidebar {
    display: none;
  }

  .app-main {
    padding: 18px 16px 36px;
  }

  .main-header {
    gap: 4px;
    margin-bottom: 22px;
  }

  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
  }

  .mobile-brand .logo-mark {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 11px;
  }

  .main-header h1 {
    font-size: 21px;
    line-height: 1.25;
  }

  .main-subtitle {
    max-width: 310px;
    font-size: 12px;
    line-height: 1.55;
  }

  .result-summary,
  .tool-grid {
    display: none;
  }

  .results-panel {
    gap: 0;
  }

  .mobile-groups {
    display: grid;
    gap: 28px;
  }

  .mobile-group {
    display: grid;
    gap: 12px;
    animation: card-in 460ms var(--ease) both;
  }

  .mobile-group:nth-child(2n) {
    animation-delay: 45ms;
  }

  .mobile-group:nth-child(3n) {
    animation-delay: 90ms;
  }

  .mobile-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
  }

  .mobile-group-head h2 {
    margin: 0;
    color: #252b34;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
  }

  .mobile-group-head span {
    background: var(--tertiary-soft);
    color: var(--tertiary);
    font-size: 12px;
    font-weight: 700;
    padding: 1px 7px;
  }

  .mobile-tool-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-tool-card {
    position: relative;
    min-height: 108px;
    border: 1px solid transparent;
    background: var(--surface);
    overflow: hidden;
    padding: 13px 28px 12px 12px;
    cursor: pointer;
    outline: 0;
    transition:
      border-color 180ms var(--ease),
      background 180ms var(--ease),
      transform 180ms var(--ease);
  }

  .mobile-tool-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 180ms var(--ease);
  }

  .mobile-tool-card h3 {
    margin: 0 0 7px;
    color: #252b34;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .mobile-tool-card p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mobile-card-arrow {
    position: absolute;
    top: 13px;
    right: 11px;
    color: var(--primary);
    font-size: 22px;
    line-height: 1;
  }

  .mobile-tool-card:active {
    border-color: rgba(37, 99, 235, 0.28);
    background: #fbfdff;
    transform: scale(0.99);
  }

  .mobile-tool-card:active::before {
    opacity: 1;
  }

  .tool-dialog {
    width: calc(100% - 20px);
  }

  .dialog-body {
    max-height: 84vh;
    padding: 22px 18px;
  }

  .dialog-close {
    top: 10px;
    right: 10px;
  }

  .dialog-head {
    padding-right: 42px;
  }

  .dialog-head h2 {
    font-size: 22px;
  }

  .site-footer {
    display: grid;
    gap: 8px;
    margin-top: 34px;
    font-size: 11px;
  }
}

@media (hover: none) {
  .filter-chip:hover {
    transform: none;
  }

  .tool-row:hover {
    border-color: transparent;
    background: var(--surface);
    box-shadow: none;
    transform: none;
  }

  .tool-row:hover::before {
    opacity: 0;
  }

  .tool-row:hover .card-arrow {
    transform: none;
  }

  .primary-link:hover {
    transform: none;
  }
}

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

@keyframes soft-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
