:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #16202e;
  --text-muted: #5c6675;
  --border: #e4e9f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --accent: #0d9488;
  --accent-hover: #0b7c72;
  --danger: #dc2626;
  --success: #16a34a;
  --diff-add-bg: #e7f6ec;
  --diff-add-fg: #14532d;
  --diff-del-bg: #fdeaea;
  --diff-del-fg: #7f1d1d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
  --max-width: 1100px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f151f;
  --surface: #171f2c;
  --surface-2: #1e2836;
  --text: #e8edf4;
  --text-muted: #9aa6b5;
  --border: #273345;
  --primary: #5b96f7;
  --primary-hover: #7caaf9;
  --primary-soft: #1b2941;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --danger: #f87171;
  --success: #4ade80;
  --diff-add-bg: #12291a;
  --diff-add-fg: #86efac;
  --diff-del-bg: #321519;
  --diff-del-fg: #fca5a5;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

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

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
header.site-header {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

nav.main-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
nav.main-nav a {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.93rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}
nav.main-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ---------- Hero ---------- */
.hero {
  padding: 60px 0 36px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  margin: 0 0 12px;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.hero p {
  color: var(--text-muted);
  font-size: 1.08rem;
  max-width: 620px;
  margin: 0 auto;
}

.search-bar {
  max-width: 480px;
  margin: 28px auto 0;
  position: relative;
}
.search-bar input {
  width: 100%;
  padding: 13px 18px 13px 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-bar::before {
  content: "🔍";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  opacity: 0.6;
  pointer-events: none;
}

/* ---------- Category sections / tool grid ---------- */
.category-section { padding: 20px 0 8px; }
.category-section > h2 {
  font-size: 1.15rem;
  margin: 18px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.category-section > h2 .cat-icon { font-size: 1.2rem; }

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

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: block;
  color: var(--text);
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  text-decoration: none;
}
.tool-card .icon { font-size: 1.7rem; margin-bottom: 10px; }
.tool-card h3 { margin: 0 0 5px; font-size: 1.02rem; }
.tool-card p { margin: 0; color: var(--text-muted); font-size: 0.88rem; line-height: 1.5; }

.no-results {
  display: none;
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
  font-size: 1.05rem;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  padding: 20px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 7px; opacity: 0.5; }

/* ---------- Tool page ---------- */
.tool-page { padding: 8px 0 56px; }
.tool-page h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  margin: 14px 0 6px;
  letter-spacing: -0.02em;
}
.tool-page .subtitle {
  color: var(--text-muted);
  margin: 0 0 26px;
  max-width: 720px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 26px;
}

@media (max-width: 480px) { .panel { padding: 18px; } }

/* ---------- Form elements ---------- */
.field-row { margin-bottom: 16px; }
.field-row:last-child { margin-bottom: 0; }
.field-row > label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
}
.field-inline {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.field-inline > div { flex: 1; min-width: 130px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  font-size: 0.93rem;
  cursor: pointer;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; line-height: 1.5; }
textarea.mono, input.mono, .mono { font-family: var(--mono); font-size: 0.88rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
input[type="color"] {
  width: 52px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
[data-theme="dark"] .btn { color: #0f151f; }
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--accent); }
.btn.secondary:hover { background: var(--accent-hover); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 42px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-size: 0.95rem;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone input[type="file"] { display: none; }

/* ---------- Results ---------- */
.result-box {
  margin-top: 20px;
  padding: 18px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: none;
}
.result-box.show { display: block; }
.result-box.static { display: block; }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; }
.stat { font-size: 0.82rem; color: var(--text-muted); }
.stat strong { color: var(--text); font-size: 1.15rem; display: block; margin-top: 2px; }

.output-area {
  width: 100%;
  min-height: 120px;
  font-family: var(--mono);
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.error-msg {
  color: var(--danger);
  font-size: 0.88rem;
  margin-top: 10px;
  display: none;
}
.error-msg.show { display: block; }

/* Diff output */
.diff-output {
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-top: 16px;
  background: var(--surface);
}
.diff-output .dline { padding: 1px 12px; white-space: pre-wrap; word-break: break-all; }
.diff-output .add { background: var(--diff-add-bg); color: var(--diff-add-fg); }
.diff-output .del { background: var(--diff-del-bg); color: var(--diff-del-fg); }

/* Hash rows */
.hash-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.hash-row .hash-name {
  font-weight: 700;
  font-size: 0.8rem;
  width: 72px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.hash-row input { flex: 1; }
.hash-row .btn { padding: 8px 12px; flex-shrink: 0; }

/* ---------- Content / SEO sections ---------- */
.content-block { color: var(--text-muted); max-width: 760px; }
.content-block h2 {
  color: var(--text);
  font-size: 1.25rem;
  margin: 34px 0 10px;
}
.content-block h3 { color: var(--text); font-size: 1.02rem; margin: 20px 0 6px; }
.content-block p { margin: 8px 0; }

/* ---------- Related tools ---------- */
.related-tools { margin-top: 44px; }
.related-tools h2 { font-size: 1.2rem; margin-bottom: 14px; }

/* ---------- Ad slots (collapsed until AdSense is active) ---------- */
.ad-slot { display: none; }
/* When ads are enabled, replace the rule above with:
.ad-slot { display: block; margin: 26px auto; text-align: center; min-height: 90px; }
*/

/* ---------- Footer ---------- */
footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0 32px;
  margin-top: 48px;
  background: var(--surface);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
}
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 440px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-grid h4 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--text-muted); font-size: 0.88rem; }
.footer-grid a:hover { color: var(--primary); }
.footer-brand { color: var(--text-muted); font-size: 0.88rem; }
.footer-brand .logo { margin-bottom: 10px; }
.footer-bottom {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------- Legal pages ---------- */
.legal-page { padding: 24px 0 56px; max-width: 760px; }
.legal-page h1 { font-size: 1.7rem; }
.legal-page h2 { font-size: 1.15rem; margin-top: 26px; }
.legal-page p, .legal-page li { color: var(--text-muted); }

/* ---------- 404 ---------- */
.notfound {
  text-align: center;
  padding: 80px 20px 60px;
}
.notfound .code { font-size: 4.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.notfound h1 { font-size: 1.5rem; margin: 16px 0 8px; }
.notfound p { color: var(--text-muted); }

/* ---------- Toast ---------- */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile nav ---------- */
@media (max-width: 560px) {
  nav.main-nav a { padding: 7px 8px; font-size: 0.88rem; }
  .hero { padding: 40px 0 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
