:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --accent: #06b6d4;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --radius: 12px;
  --transition: .2s ease;
}

[data-theme="dark"] {
  --primary: #818cf8;
  --primary-dark: #6366f1;
  --primary-light: #a5b4fc;
  --accent: #22d3ee;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* Header */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.85);
}
[data-theme="dark"] .site-header { background: rgba(15,23,42,.85); }

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.logo svg { width: 28px; height: 28px; }
.logo span.accent { color: var(--primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: .925rem;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }
.theme-toggle svg { width: 18px; height: 18px; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.mobile-menu-btn svg { width: 24px; height: 24px; }

/* Hero */
.hero {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  max-width: 800px;
  margin: 0 auto;
}
.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.search-box {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: .85rem 1rem .85rem 2.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}
.search-box input:focus { border-color: var(--primary); }
.search-box svg {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

/* Tool Grid */
.section { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title svg { width: 24px; height: 24px; color: var(--primary); }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  text-decoration: none;
  color: var(--text);
}
.tool-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
  transform: translateY(-2px);
  color: var(--text);
}
.tool-card .icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.tool-card h3 { font-size: 1.05rem; font-weight: 600; }
.tool-card p { font-size: .875rem; color: var(--text-secondary); line-height: 1.5; }

.icon-blue { background: #eff6ff; color: #3b82f6; }
.icon-green { background: #f0fdf4; color: #22c55e; }
.icon-purple { background: #faf5ff; color: #a855f7; }
.icon-orange { background: #fff7ed; color: #f97316; }
.icon-red { background: #fef2f2; color: #ef4444; }
.icon-cyan { background: #ecfeff; color: #06b6d4; }
.icon-pink { background: #fdf2f8; color: #ec4899; }
.icon-yellow { background: #fefce8; color: #eab308; }
[data-theme="dark"] .icon-blue { background: #1e3a5f; }
[data-theme="dark"] .icon-green { background: #14532d; }
[data-theme="dark"] .icon-purple { background: #3b0764; }
[data-theme="dark"] .icon-orange { background: #431407; }
[data-theme="dark"] .icon-red { background: #450a0a; }
[data-theme="dark"] .icon-cyan { background: #083344; }
[data-theme="dark"] .icon-pink { background: #500724; }
[data-theme="dark"] .icon-yellow { background: #422006; }

/* Tool Page Layout */
.tool-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.tool-header {
  margin-bottom: 2rem;
}
.tool-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: .5rem;
}
.tool-header p { color: var(--text-secondary); }

.tool-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.tool-panel label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .5rem;
  color: var(--text-secondary);
}
.tool-panel textarea,
.tool-panel input[type="text"],
.tool-panel input[type="number"],
.tool-panel select {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.tool-panel textarea:focus,
.tool-panel input:focus,
.tool-panel select:focus { border-color: var(--primary); }
.tool-panel textarea { min-height: 160px; }

.btn-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.btn {
  padding: .6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.output-area {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  min-height: 80px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .9rem;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
}
.copy-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  padding: .35rem .65rem;
  font-size: .8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.copy-btn:hover { border-color: var(--primary); color: var(--primary); }

.tool-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 2rem;
}
.tool-info h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.tool-info h3 { font-size: 1.05rem; font-weight: 600; margin: 1.25rem 0 .5rem; }
.tool-info p { color: var(--text-secondary); margin-bottom: .75rem; line-height: 1.7; }
.tool-info ul { padding-left: 1.5rem; color: var(--text-secondary); }
.tool-info li { margin-bottom: .35rem; line-height: 1.6; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }

/* Footer */
.site-footer {
  margin-top: auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 3rem 1.5rem 1.5rem;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
}
.footer-brand p { color: var(--text-secondary); font-size: .9rem; margin-top: .75rem; line-height: 1.6; }
.footer-col h4 { font-size: .9rem; font-weight: 700; margin-bottom: 1rem; text-transform: uppercase; letter-spacing: .05em; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: .5rem; }
.footer-col a { color: var(--text-secondary); font-size: .9rem; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-secondary);
  font-size: .85rem;
}

/* Content pages */
.page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.page-container h1 { font-size: 2rem; font-weight: 800; margin-bottom: 1.5rem; }
.page-container h2 { font-size: 1.35rem; font-weight: 700; margin: 2rem 0 .75rem; }
.page-container p { color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.8; }
.page-container ul, .page-container ol { padding-left: 1.5rem; color: var(--text-secondary); margin-bottom: 1rem; }
.page-container li { margin-bottom: .35rem; line-height: 1.7; }

/* Feature Section */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.feature-card {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.feature-card .feat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}
.feature-card h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: .5rem; }
.feature-card p { font-size: .875rem; color: var(--text-secondary); }

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .mobile-menu-btn { display: block; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    gap: .75rem;
    box-shadow: var(--shadow-lg);
  }
  .tool-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.65rem; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .footer-inner { grid-template-columns: 1fr; }
}

/* JSON Syntax Highlighting */
.json-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  min-height: 120px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .875rem;
  line-height: 1.65;
  overflow: auto;
  position: relative;
  display: flex;
}
.json-lines {
  padding: .75rem 0;
  min-width: 3rem;
  text-align: right;
  color: var(--text-secondary);
  opacity: .5;
  font-size: .8rem;
  line-height: 1.65;
  user-select: none;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.json-lines span { display: block; padding: 0 .6rem; }
.json-code {
  padding: .75rem 1rem;
  flex: 1;
  overflow-x: auto;
  white-space: pre;
}
.json-code .json-key { color: #2563eb; }
.json-code .json-string { color: #16a34a; }
.json-code .json-number { color: #ea580c; }
.json-code .json-bool { color: #9333ea; }
.json-code .json-null { color: #dc2626; }
.json-code .json-brace { color: var(--text); font-weight: 600; }
.json-code .json-error { color: #dc2626; font-style: italic; }
[data-theme="dark"] .json-code .json-key { color: #93c5fd; }
[data-theme="dark"] .json-code .json-string { color: #86efac; }
[data-theme="dark"] .json-code .json-number { color: #fdba74; }
[data-theme="dark"] .json-code .json-bool { color: #c4b5fd; }
[data-theme="dark"] .json-code .json-null { color: #fca5a5; }

.json-toolbar {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.json-toolbar select {
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
  width: auto;
  font-family: 'Inter', sans-serif;
}

/* Stats badges */
.stat-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .8rem;
  color: var(--text-secondary);
}
.stat-badge .val {
  font-weight: 700;
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
}
.stat-badge.ok { border-color: #22c55e; }
.stat-badge.ok .val { color: #22c55e; }
.stat-badge.warn { border-color: #f59e0b; }
.stat-badge.warn .val { color: #f59e0b; }
.stat-badge.err { border-color: #ef4444; }
.stat-badge.err .val { color: #ef4444; }

/* Tab switcher */
.tab-row {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: .6rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Split pane */
.split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 768px) {
  .split-pane { grid-template-columns: 1fr; }
}

/* Color palette */
.palette-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .75rem 0;
}
.palette-chip {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.palette-chip:hover { transform: scale(1.15); border-color: var(--primary); }
.palette-chip.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* Contrast badge */
.contrast-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: .75rem 0;
}
.contrast-ratio {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}
.contrast-badges { display: flex; gap: .5rem; flex-wrap: wrap; }
.contrast-badge {
  padding: .25rem .65rem;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 700;
}
.contrast-pass { background: #dcfce7; color: #166534; }
.contrast-fail { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .contrast-pass { background: #14532d; color: #86efac; }
[data-theme="dark"] .contrast-fail { background: #450a0a; color: #fca5a5; }

/* Diff viewer */
.diff-line { font-family: 'JetBrains Mono', monospace; font-size: .85rem; line-height: 1.7; white-space: pre-wrap; }
.diff-add { background: #dcfce7; color: #166534; }
.diff-remove { background: #fee2e2; color: #991b1b; }
.diff-context { color: var(--text-secondary); }
[data-theme="dark"] .diff-add { background: #14532d; color: #86efac; }
[data-theme="dark"] .diff-remove { background: #450a0a; color: #fca5a5; }

/* Password strength meter */
.strength-meter {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin: .5rem 0;
}
.strength-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease, background .4s ease;
}
.strength-weak { background: #ef4444; width: 25%; }
.strength-fair { background: #f59e0b; width: 50%; }
.strength-good { background: #3b82f6; width: 75%; }
.strength-strong { background: #22c55e; width: 100%; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
.animate-fade { animation: fadeIn .3s ease; }
.animate-slide { animation: slideUp .4s ease; }

.tool-card { animation: fadeIn .3s ease backwards; }
.tool-card:nth-child(1) { animation-delay: .05s; }
.tool-card:nth-child(2) { animation-delay: .1s; }
.tool-card:nth-child(3) { animation-delay: .15s; }
.tool-card:nth-child(4) { animation-delay: .2s; }
.tool-card:nth-child(5) { animation-delay: .25s; }
.tool-card:nth-child(6) { animation-delay: .3s; }

/* Tag/chip */
.chip {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.chip-primary { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
[data-theme="dark"] .chip-primary { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }

/* Toggle switch */
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  position: relative;
  transition: background var(--transition);
}
.toggle-track::after {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle-wrap input { display: none; }
.toggle-wrap input:checked + .toggle-track { background: var(--primary); }
.toggle-wrap input:checked + .toggle-track::after { transform: translateX(18px); }

/* Utility */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.gap-sm { gap: .5rem; }
.flex-center { display: flex; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
