/* ==========================================================================
   So Mark It — design system
   Inspired by the warm-neutral, information-dense directory aesthetic.
   ========================================================================== */

:root {
  --color-primary: #0F172A;
  --color-primary-light: #475569;
  --color-primary-dark: #020617;
  --color-primary-bg: #F1F5F9;

  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-soft: rgba(79, 70, 229, .08);

  --bg-primary: #FFFFFF;
  --bg-secondary: #FAFAF9;
  --bg-tertiary: #F5F5F4;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FAFAF9;
  --bg-input: #F5F5F4;

  --text-primary: #0F172A;
  --text-secondary: #44403C;
  --text-tertiary: #78716C;
  --text-inverse: #FFFFFF;

  --border-color: #E7E5E4;
  --border-color-light: #F5F5F4;

  --color-success: #16A34A;
  --color-warning: #D97706;
  --color-error: #DC2626;

  --tag-free: #16A34A;        --tag-free-bg: rgba(22, 163, 74, .08);
  --tag-freemium: #2563EB;    --tag-freemium-bg: rgba(37, 99, 235, .08);
  --tag-paid: #D97706;        --tag-paid-bg: rgba(217, 119, 6, .08);
  --tag-opensource: #0891B2;  --tag-opensource-bg: rgba(8, 145, 178, .08);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-xl: 0 8px 24px rgba(15, 23, 42, .08), 0 4px 8px rgba(15, 23, 42, .05);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;

  --text-xs: .75rem;  --text-sm: .875rem;  --text-base: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.25rem; --text-2xl: 1.5rem;
  --text-3xl: 1.875rem; --text-4xl: 2.25rem;

  --nav-height: 64px;
  --sidebar-width: 248px;
  --sidebar-width-collapsed: 68px;
  --transition-fast: .15s ease;
  --transition-normal: .25s ease;

  --hero-text: #0F172A;
  --hero-text-muted: #44403C;
  --hero-search-bg: rgba(15, 23, 42, .04);
  --hero-search-border: rgba(15, 23, 42, .12);
  --hero-search-focus-bg: #FFFFFF;
  --btn-primary-bg: #0F172A;
  --btn-primary-bg-hover: #020617;
  --btn-primary-text: #FFFFFF;
  --code-bg: #F5F5F4;
}

[data-theme="dark"] {
  --color-primary: #F8FAFC;
  --color-primary-light: #CBD5E1;
  --color-primary-dark: #FFFFFF;
  --color-primary-bg: #1E293B;

  --accent: #818CF8;
  --accent-hover: #A5B4FC;
  --accent-soft: rgba(129, 140, 248, .12);

  --bg-primary: #0B1120;
  --bg-secondary: #0F172A;
  --bg-tertiary: #1E293B;
  --bg-card: #111C33;
  --bg-card-hover: #16233D;
  --bg-input: #1E293B;

  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-tertiary: #94A3B8;
  --text-inverse: #0F172A;

  --border-color: #1E293B;
  --border-color-light: #172033;

  --tag-free: #4ADE80;        --tag-free-bg: rgba(74, 222, 128, .12);
  --tag-freemium: #60A5FA;    --tag-freemium-bg: rgba(96, 165, 250, .12);
  --tag-paid: #FBBF24;        --tag-paid-bg: rgba(251, 191, 36, .12);
  --tag-opensource: #22D3EE;  --tag-opensource-bg: rgba(34, 211, 238, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .4), 0 2px 4px rgba(0, 0, 0, .3);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, .45), 0 4px 8px rgba(0, 0, 0, .35);

  --hero-text: #F8FAFC;
  --hero-text-muted: #CBD5E1;
  --hero-search-bg: rgba(255, 255, 255, .05);
  --hero-search-border: rgba(255, 255, 255, .12);
  --hero-search-focus-bg: rgba(255, 255, 255, .08);
  --btn-primary-bg: #F1F5F9;
  --btn-primary-bg-hover: #FFFFFF;
  --btn-primary-text: #0F172A;
  --code-bg: #1E293B;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }

.skip-to-content {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
  padding: 10px 16px; border-radius: 0 0 var(--radius-md) 0; font-size: var(--text-sm);
}
.skip-to-content:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app-layout { display: flex; min-height: 100vh; overflow-x: hidden; }

/* --- Sidebar -------------------------------------------------------------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: width var(--transition-normal), transform var(--transition-normal),
              background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-header {
  padding: 0 14px;
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: var(--text-base);
  letter-spacing: -.02em; color: var(--text-primary);
  min-width: 0; white-space: nowrap;
}
.brand-mark {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 55%, #DB2777 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
  letter-spacing: -.04em;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-collapse-btn {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.sidebar-collapse-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 10px 8px 16px;
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-width: thin;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.nav-section-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-tertiary);
  padding: 12px 12px 6px;
  white-space: nowrap; overflow: hidden;
}

.category-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: none; text-align: left; width: 100%;
}
.category-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.category-item.active {
  background: var(--color-primary-bg);
  color: var(--text-primary);
  font-weight: 600;
}
[data-theme="dark"] .category-item.active { background: var(--bg-tertiary); }

.cat-icon { display: grid; place-items: center; flex-shrink: 0; opacity: .85; }
.category-item.active .cat-icon { opacity: 1; }
.cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cat-count-badge {
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 1px 6px; border-radius: var(--radius-full);
  flex-shrink: 0;
}
.category-item.active .cat-count-badge { background: var(--bg-primary); }

/* Collapsed state */
body.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .cat-name,
body.sidebar-collapsed .sidebar .cat-count-badge,
body.sidebar-collapsed .sidebar .nav-section-label,
body.sidebar-collapsed .sidebar .sidebar-footer-text { display: none; }
body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 0 8px; }
body.sidebar-collapsed .sidebar-collapse-btn { display: none; }
/* Collapsed rail: the logo doubles as the expand control, so give it a
   button-like hover target instead of looking like static branding. */
body.sidebar-collapsed .sidebar .nav-brand {
  padding: 3px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}
body.sidebar-collapsed .sidebar .nav-brand:hover {
  background: var(--bg-tertiary);
  transform: scale(1.04);
}
body.sidebar-collapsed .sidebar .nav-brand:active { transform: scale(.97); }
body.sidebar-collapsed .category-item { justify-content: center; padding: 10px 0; }
body.sidebar-collapsed .nav-section-label { padding: 12px 0 0; height: 1px; overflow: hidden; }
body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-width-collapsed); }
body.sidebar-collapsed .sidebar-nav { padding-left: 6px; padding-right: 6px; }

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  padding: 10px 12px;
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 10px;
  font-size: var(--text-sm); color: var(--text-tertiary);
  padding: 7px 8px; border-radius: var(--radius-md);
  white-space: nowrap; overflow: hidden;
}
.sidebar-footer a:hover { background: var(--bg-tertiary); color: var(--text-primary); }
body.sidebar-collapsed .sidebar-footer a { justify-content: center; padding: 8px 0; }

/* --- Main column ---------------------------------------------------------- */
.main-wrapper {
  flex: 1; min-width: 0; max-width: 100%;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-normal);
  display: flex; flex-direction: column;
}

.mobile-header {
  display: none;
  position: sticky; top: 0; z-index: 90;
  height: 56px; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}
.mobile-header-actions { display: flex; align-items: center; gap: 6px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 95;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}

/* --- Topbar --------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-primary) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}
.topbar.scrolled { box-shadow: var(--shadow-sm); }
.topbar-inner {
  max-width: 1360px; margin: 0 auto;
  padding: 0 24px; height: var(--nav-height);
  display: flex; align-items: center; gap: 16px;
}

.nav-search-wrapper { position: relative; flex: 1; max-width: 380px; }
.topbar-search { flex: 1; max-width: 420px; }
.nav-search-wrapper .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); pointer-events: none; display: flex;
}
.nav-search-input {
  width: 100%; height: 36px;
  padding: 0 12px 0 34px;
  font-size: var(--text-sm); font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}
.nav-search-input::placeholder { color: var(--text-tertiary); }
.nav-search-input:focus {
  background: var(--bg-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 34px; padding: 0 10px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-btn-primary {
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
  font-weight: 500;
}
.nav-btn-primary:hover { background: var(--btn-primary-bg-hover); color: var(--btn-primary-text); }

/* --- Hero ----------------------------------------------------------------- */
.hero {
  position: relative;
  border-bottom: 1px solid var(--border-color);
  background:
    radial-gradient(1000px 320px at 12% -10%, var(--accent-soft), transparent 70%),
    var(--bg-secondary);
  overflow: hidden;
  min-width: 0;
}
.hero-inner { max-width: 1360px; margin: 0 auto; padding: 40px 24px 36px; min-width: 0; }
.hero-combined {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  min-width: 0;
}
.hero-content { min-width: 0; }

.hero-title {
  margin: 0 0 10px;
  font-size: var(--text-4xl);
  line-height: 1.15;
  letter-spacing: -.03em;
  font-weight: 800;
  color: var(--hero-text);
}
.gradient-text {
  background: linear-gradient(100deg, #4F46E5 0%, #7C3AED 45%, #DB2777 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
[data-theme="dark"] .gradient-text {
  background: linear-gradient(100deg, #818CF8 0%, #A78BFA 45%, #F472B6 100%);
  -webkit-background-clip: text; background-clip: text;
}
.hero-subtitle {
  margin: 0 0 22px;
  font-size: var(--text-base);
  color: var(--hero-text-muted);
  max-width: 46ch;
}

.hero-search { margin-bottom: 24px; }
.hero-search-wrapper {
  position: relative;
  display: flex; align-items: center;
  background: var(--hero-search-focus-bg);
  border: 1px solid var(--hero-search-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}
.hero-search-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.hero-search-wrapper .search-icon {
  position: absolute; left: 14px; color: var(--text-tertiary);
  pointer-events: none; display: flex;
}
.hero-search-input {
  flex: 1; height: 50px;
  padding: 0 14px 0 40px;
  border: none; background: transparent; outline: none;
  font-size: var(--text-base); font-family: inherit;
  color: var(--text-primary);
}
.hero-search-input::placeholder { color: var(--text-tertiary); }
.search-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; margin-right: 6px;
  border: none; border-radius: var(--radius-md);
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
  cursor: pointer; transition: background var(--transition-fast);
  flex-shrink: 0;
}
.search-btn:hover { background: var(--btn-primary-bg-hover); }

.hero-stats { display: flex; gap: 32px; }
.hero-stat-value {
  font-size: var(--text-2xl); font-weight: 700;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  color: var(--hero-text); line-height: 1.2;
}
.hero-stat-label { font-size: var(--text-xs); color: var(--text-tertiary); }

/* --- Featured rail -------------------------------------------------------- */
.hero-featured {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-md);
  min-width: 0;
  overflow: hidden;
}
.hero-featured-title {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 12px;
  font-size: var(--text-sm); font-weight: 600;
  color: var(--text-secondary);
}
.hero-featured-title .i-flame { color: #EA580C; display: flex; }
.hero-featured-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-agent-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  min-width: 0;
  overflow: hidden;
}
.hero-agent-card:hover { background: var(--bg-tertiary); }
.hero-agent-rank {
  width: 18px; font-size: 11px; font-weight: 700;
  color: var(--text-tertiary); font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.hero-agent-logo {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg-tertiary);
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  overflow: hidden;
}
.hero-agent-logo img { width: 100%; height: 100%; object-fit: cover; }
.hero-agent-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.hero-agent-name {
  font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.hero-agent-desc {
  font-size: var(--text-xs); color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}

/* --- Content -------------------------------------------------------------- */
.content-area {
  flex: 1;
  max-width: 1360px; width: 100%;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

.content-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.content-head h2 {
  margin: 0; font-size: var(--text-xl); font-weight: 700;
  letter-spacing: -.02em;
}
.tools-count {
  font-size: var(--text-sm); color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.content-head-spacer { flex: 1; }

/* Filter chips */
.filter-bar {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 11px;
  font-size: var(--text-sm); font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition-fast);
}
.chip:hover { border-color: var(--text-tertiary); color: var(--text-primary); }
.chip.active {
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg); font-weight: 500;
}

/* Category sections */
.category-section { margin-bottom: 36px; scroll-margin-top: 80px; }
.category-section-header {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color-light);
}
.category-section-header .cat-icon { color: var(--text-secondary); }
.category-section-header .cat-name {
  font-size: var(--text-lg); font-weight: 700; letter-spacing: -.02em;
}
.cat-count { font-size: var(--text-sm); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 14px;
}

/* --- Tool card ------------------------------------------------------------ */
.tool-card {
  display: flex; flex-direction: column;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
              transform var(--transition-fast), background var(--transition-fast);
  min-width: 0;
}
.tool-card:hover {
  border-color: var(--text-tertiary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.tool-card-header {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 8px;
}
.tool-logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700; font-size: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color-light);
}
.tool-logo img { width: 100%; height: 100%; object-fit: cover; }
.tool-info { min-width: 0; flex: 1; }
.tool-name {
  margin: 0;
  font-size: var(--text-base); font-weight: 650;
  letter-spacing: -.01em; line-height: 1.4;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.tool-host { font-size: var(--text-xs); color: var(--text-tertiary); }

.badge {
  display: inline-flex; align-items: center;
  height: 17px; padding: 0 5px;
  font-size: 10px; font-weight: 600;
  border-radius: var(--radius-sm);
  letter-spacing: .01em;
}
.badge-hot { color: #DC2626; background: rgba(220, 38, 38, .09); }
.badge-new { color: #2563EB; background: rgba(37, 99, 235, .09); }
[data-theme="dark"] .badge-hot { color: #F87171; background: rgba(248, 113, 113, .14); }
[data-theme="dark"] .badge-new { color: #93C5FD; background: rgba(147, 197, 253, .14); }

.tool-desc {
  margin: 0 0 12px;
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-tags {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-bottom: 12px;
}
.tool-tag {
  font-size: 11px;
  padding: 1px 7px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

.tool-card-footer {
  display: flex; align-items: center; gap: 8px;
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border-color-light);
}
.pricing-tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  font-size: 11px; font-weight: 600;
  border-radius: var(--radius-sm);
}
.pricing-free { color: var(--tag-free); background: var(--tag-free-bg); }
.pricing-freemium { color: var(--tag-freemium); background: var(--tag-freemium-bg); }
.pricing-paid { color: var(--tag-paid); background: var(--tag-paid-bg); }
.pricing-opensource { color: var(--tag-opensource); background: var(--tag-opensource-bg); }

.tool-card-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tool-detail-link {
  font-size: var(--text-xs); color: var(--text-tertiary);
  padding: 3px 7px; border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.tool-detail-link:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.tool-visit-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px;
  font-size: var(--text-xs); font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.tool-card:hover .tool-visit-btn {
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.tool-visit-btn .arrow { transition: transform var(--transition-fast); }
.tool-visit-btn:hover .arrow { transform: translateX(2px); }

/* Empty state */
.empty-state {
  text-align: center; padding: 64px 24px;
  color: var(--text-tertiary);
}
.empty-state svg { margin-bottom: 12px; opacity: .5; }
.empty-state h3 { margin: 0 0 6px; font-size: var(--text-base); color: var(--text-secondary); }
.empty-state p { margin: 0; font-size: var(--text-sm); }

/* Tool detail page */
.detail-wrap { max-width: 860px; margin: 0 auto; padding: 32px 24px 80px; }
.detail-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); padding: 28px;
}
.detail-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.detail-logo {
  width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--bg-tertiary);
  font-size: 22px; font-weight: 700; color: var(--text-secondary); overflow: hidden;
}
.detail-logo img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { margin: 0 0 4px; font-size: var(--text-2xl); letter-spacing: -.02em; }
.detail-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: var(--text-sm); color: var(--text-tertiary); }
.detail-body { font-size: var(--text-base); line-height: 1.8; color: var(--text-secondary); margin: 18px 0 24px; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.site-footer-inner {
  max-width: 1360px; margin: 0 auto;
  padding: 28px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  font-size: var(--text-sm); color: var(--text-tertiary);
}
.footer-links { display: flex; gap: 18px; }
.footer-link:hover { color: var(--text-primary); }

/* Back to top */
.back-to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  width: 40px; height: 40px;
  display: none; place-items: center;
  border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-secondary);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: opacity var(--transition-normal), transform var(--transition-fast);
}
.back-to-top.show { display: grid; }
.back-to-top:hover { color: var(--text-primary); transform: translateY(-2px); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1100px) {
  .hero-combined { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .hero-featured-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; width: var(--sidebar-width); }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-xl); }
  body.sidebar-open .sidebar-overlay { display: block; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-width); }
  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .cat-name,
  body.sidebar-collapsed .sidebar .cat-count-badge,
  body.sidebar-collapsed .sidebar .nav-section-label,
  body.sidebar-collapsed .sidebar .sidebar-footer-text { display: block; }
  body.sidebar-collapsed .category-item { justify-content: flex-start; padding: 8px 12px; }
  body.sidebar-collapsed .sidebar-header { justify-content: space-between; padding: 0 14px; }

  .main-wrapper, body.sidebar-collapsed .main-wrapper { margin-left: 0; }
  .mobile-header { display: flex; }
  .topbar { display: none; }
  .hero-inner { padding: 28px 16px 26px; }
  .hero-title { font-size: var(--text-3xl); }
  .hero-featured { width: 100%; }
  .content-area { padding: 20px 16px 64px; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
  .hero-stats { gap: 24px; }
  .site-footer-inner { padding: 24px 16px; }
  .detail-wrap { padding: 20px 16px 64px; }
  .detail-card { padding: 20px; }
}

@media (max-width: 640px) {
  .hero-featured-list { grid-template-columns: minmax(0, 1fr); }
  .tools-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-stat-value { font-size: var(--text-xl); }
  .content-head { gap: 8px; }
  .back-to-top { right: 16px; bottom: 16px; }
  .filter-bar { width: 100%; }
}

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

@media print {
  .sidebar, .mobile-header, .sidebar-overlay, .topbar, .hero-search,
  .hero-featured, .filter-bar, .back-to-top, .skip-to-content, .site-footer { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .app-layout { display: block; }
  .tool-card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none !important; transform: none !important; }
}
