:root,
[data-theme="light"] {
  --bg: #f7f6f2;
  --surface: #f9f8f5;
  --surface-2: #fbfbf9;
  --surface-offset: #f0ede8;
  --divider: #dcd9d5;
  --border: #d4d1ca;
  --text: #28251d;
  --text-muted: #7a7974;
  --text-faint: #bab9b4;
  --primary: #01696f;
  --primary-hover: #0c4e54;
  --primary-hl: #cedcd8;
  --success: #437a22;
  --success-hl: #d4dfcc;
  --orange: #da7101;
  --orange-hl: #e7d7c4;
  --purple: #7a39bb;
  --purple-hl: #dacfde;
  --blue: #006494;
  --blue-hl: #c6d8e4;
  --muted: var(--text-muted);
  --muted-hl: var(--surface-offset);
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80/0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80/0.08);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #111110;
  --surface: #1a1918;
  --surface-2: #201f1d;
  --surface-offset: #242220;
  --divider: #2a2926;
  --border: #333230;
  --text: #d4d2cf;
  --text-muted: #7a7876;
  --text-faint: #4e4d4a;
  --primary: #4f98a3;
  --primary-hover: #227f8b;
  --primary-hl: #1f3033;
  --success: #6daa45;
  --success-hl: #1e2e17;
  --orange: #fdab43;
  --orange-hl: #2e2317;
  --purple: #a86fdf;
  --purple-hl: #231833;
  --blue: #5591c7;
  --blue-hl: #162130;
  --shadow-sm: 0 1px 2px oklch(0 0 0/0.3);
  --shadow-md: 0 4px 12px oklch(0 0 0/0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul {
  list-style: none;
}

input, button {
  font: inherit;
  color: inherit;
}

a, button, [role="button"] {
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.wrap {
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* NAV */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--divider);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-block: var(--space-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.nav-spacer {
  flex: 1;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  min-width: 210px;
}

.search-wrap input {
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-sm);
  color: var(--text);
  width: 100%;
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.theme-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.theme-btn:hover {
  background: var(--surface-offset);
  color: var(--text);
}

.cta-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.cta-btn:hover {
  background: var(--primary-hover);
}

/* HERO */
.hero {
  padding: var(--space-16) 0 var(--space-12);
  border-bottom: 1px solid var(--divider);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-hl);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
}

.hero h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin-bottom: var(--space-4);
}

.hero p, .hero-sub {
  font-size: var(--text-base);
  color: var(--text-muted);
  max-width: 52ch;
  margin-bottom: var(--space-8);
}

.stats {
  display: flex;
  gap: var(--space-8);
}

.stat-n {
  font-size: var(--text-lg);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

.stat-l {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* FILTERS */
.filters {
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--divider);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.fb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.fb:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.fb.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fc {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* GRID */
.grid-section {
  padding-block: var(--space-10);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
  gap: var(--space-4);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card[data-hidden="true"] {
  display: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  background: var(--surface-offset);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.6;
}

.b-free {
  background: var(--success-hl);
  color: var(--success);
}

.b-local {
  background: var(--primary-hl);
  color: var(--primary);
}

.b-open {
  background: var(--orange-hl);
  color: var(--orange);
}

.b-api {
  background: var(--purple-hl);
  color: var(--purple);
}

.b-win {
  background: var(--blue-hl);
  color: var(--blue);
}

.b-os {
  background: var(--surface-offset);
  color: var(--text-muted);
}

.card-name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.card-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--divider);
}

.card-cat {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.card-link {
  font-size: var(--text-xs);
  color: var(--primary);
  font-weight: 500;
}

/* EMPTY */
.empty {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-muted);
}

.empty.show {
  display: flex;
}

.empty h3 {
  color: var(--text);
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.empty p {
  font-size: var(--text-sm);
  max-width: 34ch;
}

/* SUBMIT */
.submit-section {
  padding: var(--space-16) 0;
  border-top: 1px solid var(--divider);
}

.form-inner {
  max-width: 520px;
}

.form-inner h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.form-inner > p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-6);
}

.fg {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.fg label {
  font-size: var(--text-sm);
  font-weight: 500;
}

.fg input {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: var(--text-sm);
}

.fg input:focus {
  border-color: var(--primary);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  cursor: pointer;
  border: none;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.form-msg {
  font-size: var(--text-xs);
  color: var(--success);
  margin-top: var(--space-2);
  display: none;
}

/* FOOTER */
.footer {
  border-top: 1px solid var(--divider);
  padding: var(--space-8) 0;
  margin-top: var(--space-8);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.footer-text a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-text a:hover {
  color: var(--text);
}

/* TOOL DETAILS PAGE */
.tool-hero {
  padding: var(--space-8) 0 var(--space-12);
  border-bottom: 1px solid var(--divider);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb-sep {
  color: var(--text-faint);
}

.tool-hero-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-10);
  flex-wrap: wrap;
}

.tool-hero-text {
  flex: 1;
  min-width: min(100%, 500px);
}

.tool-icon-lg {
  width: 64px;
  height: 64px;
  background: var(--surface-offset);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: var(--space-4);
}

.tool-hero-text h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}

.tool-hero-text p {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-6);
  max-width: 60ch;
}

.tool-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--surface-offset);
}

.tool-meta-side {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  flex-shrink: 0;
}

.tool-meta-side h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--divider);
}

.meta-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.meta-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.meta-val {
  font-size: var(--text-sm);
  font-weight: 600;
}

.tool-body {
  padding-block: var(--space-12);
}

.tool-body-inner {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-12);
}

.tool-content {
  font-size: var(--text-base);
  line-height: 1.7;
}

.tool-content h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
}

.tool-content p {
  margin-bottom: var(--space-4);
}

.tool-content ul {
  list-style: disc;
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
}

.tool-content li {
  margin-bottom: var(--space-2);
}

.tool-content pre {
  background: var(--surface-offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.tool-content code {
  font-family: var(--font-mono);
  background: var(--surface-offset);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.tool-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.tool-content a {
  color: var(--primary);
  text-decoration: underline;
}

.tool-content a:hover {
  color: var(--primary-hover);
}

.tool-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.sidebar-card h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-tags {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  background: var(--surface-2);
}

.sidebar-link:last-child {
  margin-bottom: 0;
}

.sidebar-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.related-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  margin-bottom: var(--space-3);
  background: var(--surface-2);
}

.related-card:last-child {
  margin-bottom: 0;
}

.related-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.related-icon {
  width: 36px;
  height: 36px;
  background: var(--surface-offset);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.related-name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.related-cat {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .tool-body-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .search-wrap {
    display: none;
  }
  .hero {
    padding: var(--space-10) 0 var(--space-8);
  }
  .stats {
    gap: var(--space-6);
  }
  .fc {
    display: none;
  }
}