/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Instrument Sans', sans-serif;
  background: #080b12;
  color: #e2e8f0;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ===== TYPOGRAPHY ===== */
h1,h2,h3,h4 { font-family: 'Syne', sans-serif; }
code, pre, .mono { font-family: 'DM Mono', monospace; }

/* ===== LAYOUT ===== */
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,11,18,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
  flex-wrap: nowrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
  z-index: 102;
  position: relative;
}

.logo-mark {
  font-size: 22px;
  color: #7ee8a2;
  font-weight: 700;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: #f1f5f9;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header-nav a {
  text-decoration: none;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.header-nav a:hover { color: #f1f5f9; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  flex-shrink: 0;
  z-index: 102;
  position: relative;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #94a3b8;
  border-radius: 2px;
  transition: all 0.3s;
}

/* ===== HERO ===== */
.hero {
  padding: 100px 0 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(126,232,162,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 60%, rgba(99,102,241,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  background: rgba(126,232,162,0.1);
  border: 1px solid rgba(126,232,162,0.25);
  color: #7ee8a2;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 28px;
}

.hero-title {
  font-size: clamp(2.8rem, 7vw, 5.2rem);
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.08;
  letter-spacing: -2px;
  margin-bottom: 22px;
}

.hero-title em {
  font-style: normal;
  background: linear-gradient(135deg, #7ee8a2 0%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: #94a3b8;
  max-width: 480px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

/* ===== SEARCH ===== */
.search-wrap {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
}

.search-wrap input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 14px 46px 14px 20px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 1rem;
  color: #f1f5f9;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.search-wrap input::placeholder { color: #475569; }
.search-wrap input:focus {
  border-color: rgba(126,232,162,0.5);
  background: rgba(255,255,255,0.07);
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #475569;
  font-size: 1.3rem;
  pointer-events: none;
}

/* ===== AD SLOTS ===== */
.ad-slot {
  min-height: 90px;
  background: rgba(255,255,255,0.02);
  border: 1px dashed rgba(255,255,255,0.06);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px auto;
}
.ad-top { margin-top: 0; }
.ad-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #334155;
  font-weight: 600;
}
.sidebar-ad { min-height: 250px; }

/* ===== TOOLS GRID ===== */
.tools-grid-section { padding: 0 0 60px; }

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

.tool-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 20px 22px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.tool-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: rgba(126,232,162,0.25);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tool-card:hover::after { opacity: 1; }

.tool-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-info { flex: 1; min-width: 0; }

.tool-info h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.tool-info p {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.4;
}

.tool-arrow {
  font-size: 1.1rem;
  color: #334155;
  transition: color 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.tool-card:hover .tool-arrow {
  color: #7ee8a2;
  transform: translateX(4px);
}

/* ===== ABOUT SECTION ===== */
.about-section {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 80px 0;
}

.about-inner {
  display: flex;
  gap: 80px;
  align-items: center;
}

.about-text h2 {
  font-size: 2rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.about-text p {
  color: #94a3b8;
  line-height: 1.8;
  margin-bottom: 12px;
}

.about-stats {
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex-shrink: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-num {
  font-family: 'Syne', sans-serif;
  font-size: 2.8rem;
  font-weight: 800;
  color: #7ee8a2;
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 28px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-copy {
  font-size: 0.82rem;
  color: #475569;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  font-size: 0.82rem;
  color: #475569;
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover { color: #94a3b8; }

/* ===== TOOL PAGE ===== */
.tool-page-header {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 16px 0;
}

.tool-page-header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
}

.back-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: #94a3b8;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.85rem;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.back-btn:hover { color: #f1f5f9; border-color: rgba(255,255,255,0.25); }

.tool-page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: #f1f5f9;
}

.tool-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  padding-top: 32px;
  padding-bottom: 60px;
  align-items: start;
}

.tool-main { min-width: 0; }
.tool-sidebar { position: sticky; top: 80px; }

/* ===== TOOL UI COMPONENTS ===== */
.tool-section {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

.tool-section-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
  margin-bottom: 16px;
}

.tool-textarea,
.tool-input,
.tool-select {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: #e2e8f0;
  font-family: 'DM Mono', monospace;
  font-size: 0.88rem;
  padding: 12px 16px;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
  line-height: 1.6;
}

.tool-input {
  font-family: 'Instrument Sans', sans-serif;
  resize: none;
}

.tool-textarea:focus,
.tool-input:focus,
.tool-select:focus {
  border-color: rgba(126,232,162,0.4);
}

.tool-textarea::placeholder,
.tool-input::placeholder { color: #334155; }

.tool-select {
  font-family: 'Instrument Sans', sans-serif;
  cursor: pointer;
}
.tool-select option { background: #0f172a; }

.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.tool-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 9px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: #7ee8a2;
  color: #042714;
}
.btn-primary:hover { background: #9df0b5; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); color: #f1f5f9; }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Output area */
.output-area {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 16px;
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  min-height: 120px;
  word-break: break-all;
  white-space: pre-wrap;
  color: #a8c8e8;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: 'Instrument Sans', sans-serif;
  transition: all 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,0.15); color: #f1f5f9; }
.copy-btn.copied { color: #7ee8a2; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: rgba(74,222,128,0.12); color: #4ade80; border: 1px solid rgba(74,222,128,0.2); }
.badge-error { background: rgba(248,113,113,0.12); color: #f87171; border: 1px solid rgba(248,113,113,0.2); }
.badge-info { background: rgba(96,165,250,0.12); color: #60a5fa; border: 1px solid rgba(96,165,250,0.2); }

/* JSON syntax highlighting */
.json-string { color: #86efac; }
.json-number { color: #fbbf24; }
.json-boolean { color: #f87171; }
.json-null { color: #94a3b8; }
.json-key { color: #7dd3fc; }

/* Regex highlights */
.regex-match {
  background: rgba(251,191,36,0.25);
  border-bottom: 2px solid #fbbf24;
  border-radius: 2px;
}

/* Diff highlighting */
.diff-add { background: rgba(74,222,128,0.15); color: #86efac; display: block; }
.diff-remove { background: rgba(248,113,113,0.15); color: #fca5a5; display: block; text-decoration: line-through; }
.diff-equal { color: #94a3b8; display: block; }

/* Color swatch */
.color-swatch {
  width: 100%;
  height: 80px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
  transition: background 0.2s;
}

/* Related tools */
.related-tools h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  margin-bottom: 12px;
  font-weight: 700;
}

.related-tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.related-tool-item:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.07);
}
.related-tool-item .rt-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.related-tool-item span {
  font-size: 0.83rem;
  color: #94a3b8;
}

/* Toggle tab */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  color: #64748b;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active {
  background: rgba(255,255,255,0.08);
  color: #f1f5f9;
}

/* UTM result URL */
.utm-result {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(126,232,162,0.2);
  border-radius: 10px;
  padding: 16px;
  word-break: break-all;
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  color: #7ee8a2;
  min-height: 60px;
  line-height: 1.7;
}

/* JWT parts */
.jwt-part {
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}
.jwt-header { background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.15); }
.jwt-payload { background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.15); }
.jwt-sig { background: rgba(74,222,128,0.08); border: 1px solid rgba(74,222,128,0.15); }
.jwt-part-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.jwt-header .jwt-part-title { color: #f87171; }
.jwt-payload .jwt-part-title { color: #60a5fa; }
.jwt-sig .jwt-part-title { color: #4ade80; }

/* Markdown preview */
.md-preview {
  padding: 20px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  min-height: 200px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #e2e8f0;
}
.md-preview h1,.md-preview h2,.md-preview h3 { color: #f8fafc; margin: 16px 0 8px; }
.md-preview code { background: rgba(255,255,255,0.07); padding: 1px 6px; border-radius: 4px; font-family: 'DM Mono',monospace; font-size: 0.85em; }
.md-preview pre { background: rgba(0,0,0,0.5); padding: 14px; border-radius: 8px; overflow-x: auto; }
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote { border-left: 3px solid #475569; padding-left: 16px; color: #94a3b8; }
.md-preview a { color: #60a5fa; }
.md-preview ul,.md-preview ol { padding-left: 24px; }
.md-preview table { border-collapse: collapse; width: 100%; }
.md-preview th,.md-preview td { border: 1px solid rgba(255,255,255,0.1); padding: 8px 12px; text-align: left; }
.md-preview th { background: rgba(255,255,255,0.05); }

/* Hreflang table */
.hreflang-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.hreflang-table th { 
  text-align: left; padding: 10px 12px; 
  background: rgba(255,255,255,0.04); 
  border-bottom: 1px solid rgba(255,255,255,0.07); 
  color: #64748b; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
}
.hreflang-table td { 
  padding: 10px 12px; 
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #94a3b8;
  font-family: 'DM Mono', monospace;
}
.hreflang-table tr:last-child td { border-bottom: none; }
.hreflang-remove {
  background: none; border: none; color: #ef4444; cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 0.85rem;
  transition: background 0.15s;
}
.hreflang-remove:hover { background: rgba(239,68,68,0.1); }

/* Notification toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(30,41,59,0.95);
  border: 1px solid rgba(126,232,162,0.3);
  color: #7ee8a2;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 9999;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
  .tool-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .about-inner { flex-direction: column; gap: 40px; }
  .about-stats { flex-direction: row; justify-content: center; gap: 48px; }
}

@media (max-width: 640px) {
  .hamburger { display: flex; }
  
  /* FIXED: Mobile Navigation Overlay */
  .header-nav {
    position: fixed;
    top: 60px; /* Force menu to sit exactly below the 60px header */
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    background: #080b12; /* Solid background prevents visual overlap */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    z-index: 99; /* Sits below the header (100) */
    padding-bottom: 60px; /* Slight offset to visually center items */
    
    /* Replaces abrupt display: none with a smooth fade */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }
  
  .header-nav.open { 
    opacity: 1;
    visibility: visible;
  }
  
  .header-nav a { 
    font-size: 1.3rem; 
  }
  
  .hero { padding: 60px 0 50px; }
  .tools-grid { grid-template-columns: 1fr; }
  .tool-row { grid-template-columns: 1fr; }
  .tool-row-3 { grid-template-columns: 1fr 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
  .tool-sidebar { grid-template-columns: 1fr; }
  .about-stats { flex-direction: column; gap: 20px; align-items: flex-start; }
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: #64748b; font-size: 0.82rem; }
.text-success { color: #4ade80; }
.text-error { color: #f87171; }

/* Scroll to top button */
#scrollTop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #94a3b8;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 500;
}
#scrollTop:hover { background: rgba(255,255,255,0.15); color: #f1f5f9; }
#scrollTop.visible { display: flex; }