/* ==========================================================================
   FormatKit — Free Online Developer Tools
   Main stylesheet (no frameworks, no build step)
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #7c3aed;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --err-bg: #fef2f2;
  --err-text: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Header & navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffffee;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: -.5px;
}
.logo-mark code { font-family: var(--mono); font-size: .8rem; font-weight: 700; }
.logo em { font-style: normal; color: var(--primary); }

.main-nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }

.main-nav > ul {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0; padding: 0;
}

.main-nav li { position: relative; }

.main-nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: .92rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.main-nav .nav-link:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }

.nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  display: none;
  z-index: 110;
}
.main-nav li:hover > .nav-dropdown,
.main-nav li:focus-within > .nav-dropdown { display: block; }

.nav-dropdown a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
}
.nav-dropdown a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav-dropdown .dd-note {
  padding: 6px 10px 2px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.header-search { position: relative; flex: 0 1 260px; min-width: 175px; }

.header-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: .9rem;
  background: var(--bg);
}
.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.header-search .search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .9rem;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 340px;
  overflow: auto;
  display: none;
  z-index: 120;
}
.search-results.open { display: block; }
.search-results a {
  display: block;
  padding: 9px 14px;
  color: var(--text);
}
.search-results a:hover, .search-results a.active { background: var(--primary-soft); text-decoration: none; }
.search-results .sr-name { font-weight: 600; font-size: .9rem; }
.search-results .sr-cat { font-size: .75rem; color: var(--muted); }
.search-results .sr-empty { padding: 12px 14px; color: var(--muted); font-size: .9rem; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.15rem;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #7c3aed 100%);
  color: #fff;
  padding: 64px 0 72px;
  margin-bottom: 40px;
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.2;
  letter-spacing: -.02em;
}
.hero p.lead {
  margin: 0 0 24px;
  font-size: 1.08rem;
  max-width: 640px;
  color: #e0e7ff;
}
.hero-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.hero-badges span {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .25);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-actions .btn-light { background: #fff; color: var(--primary); }
.hero-actions .btn-ghost-light { border: 1px solid rgba(255,255,255,.5); color: #fff; background: transparent; }
.hero-actions .btn-ghost-light:hover { background: rgba(255,255,255,.12); text-decoration: none; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 7px; }
.btn.copied { background: var(--ok-bg); color: var(--ok-text); border-color: #a7f3d0; }

/* --------------------------------------------------------------------------
   Sections, cards, tool grid
   -------------------------------------------------------------------------- */

.section { margin: 40px 0; }
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  margin: 0 0 6px;
}
.section-sub { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }

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

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tool-card:hover {
  text-decoration: none;
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.tool-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  font-size: 1.15rem;
}
.tool-card h3 { margin: 0 0 2px; font-size: .95rem; line-height: 1.35; }
.tool-card p { margin: 0; font-size: .8rem; color: var(--muted); line-height: 1.45; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.feature-card h3 { margin: 0 0 6px; font-size: 1rem; }
.feature-card p { margin: 0; font-size: .88rem; color: var(--muted); }
.feature-card .tool-icon { margin-bottom: 10px; }

/* --------------------------------------------------------------------------
   Page layout with sidebar (tool pages & static pages)
   -------------------------------------------------------------------------- */

.page-head { margin: 28px 0 8px; }

.breadcrumb {
  font-size: .82rem;
  color: var(--muted);
  margin: 20px 0 10px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 6px; color: var(--border); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
  margin: 12px 0 40px;
}

h1.page-title {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.25;
  letter-spacing: -.01em;
}
p.page-lead { color: var(--muted); margin: 0 0 20px; font-size: 1rem; max-width: 720px; }

/* --------------------------------------------------------------------------
   Tool panel
   -------------------------------------------------------------------------- */

.tool-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.tool-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  padding: 4px 2px 14px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 14px;
}
.tool-options .opt { display: flex; align-items: center; gap: 8px; font-size: .86rem; }
.tool-options label { font-weight: 600; }
.tool-options select, .tool-options input[type="number"], .tool-options input[type="text"] {
  font: inherit;
  font-size: .86rem;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.tool-options input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

.tool-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 6px;
}

textarea.tool-io {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  font-family: var(--mono);
  font-size: .85rem;
  line-height: 1.5;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfdff;
  color: var(--text);
  tab-size: 2;
}
textarea.tool-io:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea.tool-io[readonly] { background: #f8fafc; color: #1e293b; }

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tool-message {
  display: none;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 14px;
  word-break: break-word;
}
.tool-message.show { display: block; }
.tool-message.ok { background: var(--ok-bg); color: var(--ok-text); border: 1px solid #a7f3d0; }
.tool-message.err { background: var(--err-bg); color: var(--err-text); border: 1px solid #fecaca; }

.tool-note { font-size: .8rem; color: var(--muted); margin-top: 10px; }

/* Stats grid (word counter, hash output, timestamp, text case) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.stat-box {
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 10px 14px;
}
.stat-box .stat-num { font-size: 1.35rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-box .stat-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.hash-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.hash-table th, .hash-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.hash-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.hash-table td.hash { font-family: var(--mono); font-size: .78rem; word-break: break-all; }

.case-list { display: grid; gap: 12px; }
.case-row .tool-label { margin-bottom: 4px; }
.case-row .case-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: .85rem;
  word-break: break-all;
}

/* --------------------------------------------------------------------------
   Ad slots
   -------------------------------------------------------------------------- */

.ad-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  margin: 22px 0;
  overflow: hidden;
  min-height: 100px;
  padding: 10px;
}
.ad-slot .ad-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #94a3b8;
}
.ad-slot .ad-size { font-size: .72rem; color: #b6c2d2; }
.ad-slot[data-ad="header"] { min-height: 100px; }
.ad-slot[data-ad="sidebar"] { min-height: 260px; }
.ad-slot[data-ad="in-content"] { min-height: 120px; }
.ad-slot[data-ad="footer"] { min-height: 100px; }
.ad-slot.ad-filled { border: 0; background: transparent; padding: 0; }
.ad-slot .adsbygoogle { width: 100%; }

/* Sponsored / affiliate promo box */
.promo-box {
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border: 1px solid #e0e7ff;
  border-radius: var(--radius);
  padding: 16px;
  margin: 22px 0;
}
.promo-box .promo-tag {
  display: inline-block;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: #ede9fe;
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 8px;
}
.promo-box h4 { margin: 0 0 6px; font-size: .95rem; }
.promo-box p { margin: 0 0 10px; font-size: .84rem; color: var(--muted); }
.promo-box a.promo-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  padding: 7px 14px;
  border-radius: 8px;
}
.promo-box a.promo-link:hover { background: #6d28d9; text-decoration: none; }

.sponsor-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 26px 0;
}
.sponsor-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: .84rem;
}
.sponsor-item .sponsor-badge {
  display: block;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 8px;
}

/* --------------------------------------------------------------------------
   Article content (SEO text, policies)
   -------------------------------------------------------------------------- */

.article {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-top: 24px;
}
.article h2 { font-size: 1.15rem; margin: 26px 0 8px; }
.article h2:first-child { margin-top: 0; }
.article h3 { font-size: 1rem; margin: 20px 0 6px; }
.article p, .article li { font-size: .92rem; color: #334155; }
.article ul, .article ol { padding-left: 22px; }
.article table { border-collapse: collapse; width: 100%; font-size: .86rem; margin: 12px 0; }
.article th, .article td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article th { background: var(--bg); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  margin-top: 60px;
  padding: 48px 0 24px;
  font-size: .88rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px 32px;
  margin-bottom: 32px;
}
.footer-brand .logo { color: #fff; margin-bottom: 10px; }
.footer-brand p { color: #94a3b8; font-size: .85rem; max-width: 300px; }
.footer-col h4 {
  color: #fff;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 12px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: #cbd5e1; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  justify-content: space-between;
  color: #94a3b8;
  font-size: .8rem;
}
.footer-bottom a { color: #94a3b8; }
.footer-bottom a:hover { color: #fff; }

/* --------------------------------------------------------------------------
   Cookie consent banner
   -------------------------------------------------------------------------- */

.cookie-banner {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 200;
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, .25);
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.cookie-banner .cookie-text { flex: 1 1 320px; font-size: .86rem; color: #334155; margin: 0; }
.cookie-banner .cookie-text a { font-weight: 600; }
.cookie-banner .cookie-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Contact form
   -------------------------------------------------------------------------- */

.contact-form {
  display: grid;
  gap: 14px;
  max-width: 560px;
}
.contact-form label { font-weight: 600; font-size: .88rem; }
.contact-form input, .contact-form textarea, .contact-form select {
  width: 100%;
  font: inherit;
  font-size: .9rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}
.contact-form input:focus, .contact-form textarea:focus, .contact-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.contact-form textarea { min-height: 140px; resize: vertical; }
.form-status { font-size: .88rem; font-weight: 600; display: none; }
.form-status.show { display: block; }
.form-status.ok { color: var(--ok-text); }
.form-status.err { color: var(--err-text); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .layout-aside { order: 2; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 64px);
    overflow: auto;
    padding: 10px 20px 20px;
  }
  .site-header.nav-open .main-nav { display: block; }
  .main-nav > ul { flex-direction: column; align-items: stretch; gap: 0; }
  .main-nav > ul > li { border-bottom: 1px solid var(--border); }
  .main-nav > ul > li:last-child { border-bottom: 0; }
  .main-nav .nav-link { width: 100%; justify-content: space-between; padding: 12px 4px; }
  .nav-dropdown {
    display: block;
    position: static;
    box-shadow: none;
    border: 0;
    padding: 0 0 8px 8px;
    min-width: 0;
  }
  .nav-dropdown a { padding: 7px 10px; }
  .header-search { flex: 1 1 100%; order: -1; margin: 10px 0; }
  .header-inner { flex-wrap: wrap; padding: 8px 0; }
  .hero { padding: 44px 0 52px; }
}

@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; }
  .tool-panel { padding: 14px; }
  .cookie-banner { left: 10px; right: 10px; bottom: 10px; }
}
