:root {
  --bg: #F8FAFC;
  --bg2: #F1F5F9;
  --bg3: #E2E8F0;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text2: #475569;
  --text3: #94A3B8;
  --accent: #2563EB;
  --accent-light: #EFF6FF;
  --accent-dark: #1D4ED8;
  --border: #E2E8F0;
  --border2: #CBD5E1;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  line-height: 1.2;
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-logo {
  position: relative;
  z-index: 2;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.nav-logo span { color: var(--accent); }

.nav-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white;
}

.nav-search {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  z-index: 1;
}

.nav-search input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  border: 1.5px solid var(--border2);
  border-radius: 99px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.nav-search input:focus { border-color: var(--accent); background: white; }
.nav-search input::placeholder { color: var(--text3); }

.nav-search .search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 15px;
  pointer-events: none;
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: auto;
  position: relative;
  z-index: 2;
}

.nav-links a {
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--bg2); color: var(--text); }
.nav-links a.active { background: var(--accent-light); color: var(--accent); }

/* ── HERO ── */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 56px 24px 48px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
  margin-bottom: 20px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -.02em;
  max-width: 700px;
  margin: 0 auto 16px;
}

.hero h1 .accent { color: var(--accent); }

.hero p {
  font-size: 17px;
  color: var(--text2);
  max-width: 520px;
  margin: 0 auto 32px;
  font-weight: 400;
}

.hero-search {
  max-width: 580px;
  margin: 0 auto 28px;
  position: relative;
}

.hero-search input {
  width: 100%;
  padding: 16px 60px 16px 24px;
  border: 2px solid var(--border2);
  border-radius: 99px;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-md);
  transition: border-color .2s, box-shadow .2s;
}
.hero-search input:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 4px rgba(37,99,235,.1), var(--shadow-md);
}
.hero-search input::placeholder { color: var(--text3); }

.hero-search-btn {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 99px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  cursor: pointer;
  transition: background .15s;
}
.hero-search-btn:hover { background: var(--accent-dark); }

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}
.hero-stat .num {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.hero-stat .lbl {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

/* ── MAIN LAYOUT ── */
.main { max-width: 1280px; margin: 0 auto; padding: 32px 24px; }

/* ── CATEGORY PILLS ── */
.category-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.cat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
.cat-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.cat-pill.active { background: var(--accent); border-color: var(--accent); color: white; }
.cat-pill .cat-icon { font-size: 14px; }
.cat-pill .cat-count {
  font-size: 11px;
  background: rgba(0,0,0,.08);
  padding: 1px 6px;
  border-radius: 99px;
}
.cat-pill.active .cat-count { background: rgba(255,255,255,.25); }

/* ── SECTION HEADER ── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}
.section-header a {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* ── TOOLS GRID ── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 40px;
}

.tool-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all .18s;
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .2s;
  transform-origin: left;
}
.tool-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.tool-card:hover::before { transform: scaleX(1); }

.tool-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}

.tool-card-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.tool-card-desc {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-card-badge {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-popular { background: #FEF3C7; color: #92400E; }
.badge-new { background: #D1FAE5; color: #065F46; }

/* ── CATEGORY SECTION ── */
.category-section { margin-bottom: 44px; }
.category-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--border);
}
.category-section-header .icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.category-section-header h2 {
  font-size: 18px;
  font-weight: 700;
}
.category-section-header .count {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
  background: var(--bg2);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ── SEARCH RESULTS ── */
#search-results { display: none; }
#search-results.active { display: block; }
#main-content.hidden { display: none; }
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.no-results h3 { font-size: 20px; margin-bottom: 8px; color: var(--text2); }

/* ── FEATURED ── */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.featured-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  cursor: pointer;
  transition: all .18s;
  text-decoration: none;
}
.featured-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.featured-card .fc-icon {
  width: 48px; height: 48px; min-width: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.featured-card .fc-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.featured-card .fc-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

/* ── FOOTER ── */
.footer {
  background: var(--text);
  color: var(--text3);
  padding: 48px 24px 28px;
  margin-top: 40px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}
.footer-brand .logo {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: white;
  margin-bottom: 10px;
}
.footer-brand .logo span { color: #60A5FA; }
.footer-brand p {
  font-size: 13px;
  line-height: 1.7;
  max-width: 260px;
}
.footer-col h4 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 14px;
}
.footer-col a {
  display: block;
  color: var(--text3);
  font-size: 13px;
  margin-bottom: 8px;
  text-decoration: none;
  transition: color .15s;
}
.footer-col a:hover { color: white; text-decoration: none; }
.footer-bottom {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
}

/* ── TOOL PAGE ── */
.tool-page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 32px 24px;
}
.breadcrumb {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.breadcrumb a { color: var(--text3); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--border2); }

.tool-page-header h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}
.tool-page-header p {
  font-size: 16px;
  color: var(--text2);
  max-width: 600px;
}

.tool-page-main {
  max-width: 900px;
  margin: 32px auto;
  padding: 0 24px;
}

.tool-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 28px;
}

.tool-box h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Form elements */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  background: white;
}
.form-textarea {
  min-height: 160px;
  resize: vertical;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  cursor: pointer;
  transition: all .15s;
  border: none;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.output-area {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  min-height: 80px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.result-card {
  background: var(--accent-light);
  border: 1.5px solid #BFDBFE;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-top: 16px;
}
.result-card .result-num {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}
.result-card .result-label {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
}

/* FAQ */
.faq { margin-bottom: 28px; }
.faq h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.faq-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-q {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  user-select: none;
}
.faq-q:hover { background: var(--bg2); }
.faq-q .arrow { transition: transform .2s; font-size: 12px; color: var(--text3); }
.faq-item.open .faq-q .arrow { transform: rotate(180deg); }
.faq-a {
  padding: 0 18px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s, padding .25s;
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}
.faq-item.open .faq-a { max-height: 300px; padding: 12px 18px 16px; }

/* Related tools */
.related { margin-bottom: 28px; }
.related h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.related-card {
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all .15s;
}
.related-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

/* Copy btn */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  transition: all .15s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: #059669; border-color: #059669; background: #D1FAE5; }

/* Alert */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}
.alert.show { display: block; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #6EE7B7; }
.alert-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }

/* Range slider */
.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.range-row label { font-size: 13px; font-weight: 600; min-width: 120px; }
.range-row input[type=range] { flex: 1; }
.range-row .range-val {
  font-size: 13px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
  color: var(--accent);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
}
.checkbox-row input { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent); }

/* How to use */
.how-to { margin-bottom: 28px; }
.how-to h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  width: 28px; height: 28px; min-width: 28px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
.step-text { font-size: 14px; color: var(--text2); line-height: 1.6; padding-top: 4px; }

/* Progress bar */
.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .3s;
}

/* Color chip */
.color-chip {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  margin-bottom: 10px;
  transition: all .2s;
}

/* Toggle */
.toggle-group {
  display: flex;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
.toggle-btn {
  flex: 1;
  padding: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all .15s;
  color: var(--text2);
}
.toggle-btn.active { background: var(--accent); color: white; }

/* Responsive */
@media (max-width: 768px) {
  .nav { padding: 0 16px; gap: 10px; height: 60px; }
  .nav-links { display: none; }
  /* On tablet/mobile: exit absolute centering, let search flex normally */
  .nav-search {
    position: static;
    transform: none;
    flex: 1;
    max-width: 100%;
    min-width: 0;
  }
  .hero { padding: 36px 16px 32px; }
  .main { padding: 20px 16px; }
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
  .tool-page-main { padding: 0 16px; }
}
@media (max-width: 480px) {
  .nav { height: 56px; padding: 0 12px; gap: 8px; }
  .nav-search input { font-size: 13px; padding: 8px 12px 8px 34px; }
  .nav-logo { font-size: 17px; }
  .nav-logo .logo-icon { width: 30px; height: 30px; font-size: 14px; }
  .hero h1 { font-size: 26px; }
  .footer-inner { grid-template-columns: 1fr; }
  .hero-stats { gap: 20px; }
}
