/* ===== Design tokens ===== */
:root {
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --border: #E3E7EC;
  --text: #14181F;
  --muted: #5B6472;
  --accent: #0F766E;
  --accent-strong: #0B5C56;
  --accent-tint: #E4F3F1;
  --danger: #B4262E;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --max-width: 720px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0B1220;
  --card: #121A2A;
  --border: #223047;
  --text: #E7ECF5;
  --muted: #93A0B4;
  --accent: #2DD4BF;
  --accent-strong: #5EEAD4;
  --accent-tint: rgba(45, 212, 191, 0.12);
  --shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

@font-face { font-family: "Manrope"; src: local("Manrope"); }
@font-face { font-family: "Inter"; src: local("Inter"); }

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

h1, h2, h3, .brand__name { font-family: var(--font-ui); font-weight: 700; letter-spacing: -0.01em; }

a { color: var(--accent-strong); }

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

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent);
  color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Header ===== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.site-header__inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand__mark { width: 22px; height: 22px; color: var(--accent); }
.brand__name { font-size: 17px; }

.site-search { position: relative; flex: 1; max-width: 380px; margin-left: auto; }
.site-search__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.site-search input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 14px;
}
.site-search__results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 30;
}
.site-search__results a {
  display: block; padding: 10px 14px; text-decoration: none; color: var(--text); font-size: 14px;
}
.site-search__results a:hover, .site-search__results a:focus { background: var(--accent-tint); }
.site-search__empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }

.icon-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .icon-moon { display: none; }
html[data-theme="dark"] .icon-btn .icon-sun { display: none; }
html[data-theme="dark"] .icon-btn .icon-moon { display: block; }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; }
.site-footer__inner {
  max-width: 1080px; margin: 0 auto; padding: 28px 24px;
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between;
  color: var(--muted); font-size: 14px;
}
.site-footer nav a { color: var(--muted); margin-right: 16px; text-decoration: none; }
.site-footer nav a:hover { color: var(--accent-strong); }

/* ===== Eyebrow ===== */
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em;
  color: var(--accent-strong); text-transform: uppercase; margin: 0 0 10px;
}

/* ===== Homepage ===== */
.home { max-width: 1080px; margin: 0 auto; padding: 48px 24px 64px; }
.hero { max-width: 640px; margin-bottom: 48px; }
.hero h1 { font-size: 40px; margin: 0 0 12px; }
.hero__lede { color: var(--muted); font-size: 17px; margin: 0; }

.home-section { margin-bottom: 48px; }
.home-section h2 { font-size: 20px; margin: 0 0 16px; }

.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px;
}
.tool-tile {
  display: flex; flex-direction: column; gap: 10px; padding: 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.tool-tile:hover, .tool-tile:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.tool-tile__icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent-tint); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
}
.tool-tile__icon svg { width: 18px; height: 18px; }
.tool-tile__title { font-family: var(--font-ui); font-weight: 700; font-size: 15px; }
.tool-tile__desc { color: var(--muted); font-size: 13px; margin: 0; }

/* ===== Tool page ===== */
.tool-page { max-width: var(--max-width); margin: 0 auto; padding: 48px 24px 64px; }
.tool-page h1 { font-size: 30px; margin: 0 0 8px; }
.tool-page__lede { color: var(--muted); margin: 0 0 28px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; margin-bottom: 32px;
}

.field-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.mode-tab { position: relative; }
.mode-tab input { position: absolute; opacity: 0; }
.mode-tab span {
  display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 13px; cursor: pointer; color: var(--muted);
}
.mode-tab input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-tab input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: var(--font-mono); font-size: 16px;
}
.field input:focus { border-color: var(--accent); }
.field__hint { font-size: 12px; color: var(--danger); margin: 6px 0 0; min-height: 14px; }

.result-block { text-align: center; padding: 20px 0 8px; }
.result-block--secondary { padding: 4px 0; }
.result-block__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 4px; }
.result-block__value { font-family: var(--font-mono); font-size: 40px; font-weight: 600; color: var(--accent-strong); margin: 0; word-break: break-word; }
.result-block__value--small { font-size: 16px; font-weight: 500; color: var(--text); }

.tool-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.tool-actions__status { min-height: 18px; font-size: 13px; color: var(--muted); margin: 8px 0 0; }

.btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 14px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer;
}
.btn--ghost { background: transparent; color: var(--accent-strong); }
.btn:hover { filter: brightness(0.95); }
#btn-fullscreen[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }

.content-block { margin-bottom: 32px; }
.content-block h2 { font-size: 18px; margin: 0 0 12px; }
.content-block p, .content-block li { color: var(--muted); }
.content-block dt { font-weight: 700; color: var(--text); margin-top: 14px; }
.content-block dd { margin: 4px 0 0; color: var(--muted); }

.related__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

code {
  font-family: var(--font-mono); font-size: 0.9em; background: var(--accent-tint);
  color: var(--accent-strong); padding: 2px 5px; border-radius: 4px;
}
pre {
  font-family: var(--font-mono); font-size: 13px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; margin: 0 0 14px;
}
pre code {
  background: none; color: inherit; padding: 0; border-radius: 0;
}

@media (max-width: 640px) {
  .tool-grid, .related__grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 30px; }
  .site-header__inner { padding: 14px 16px; gap: 10px; }
  .brand { flex-shrink: 0; }
  .brand__name { display: none; }
  .site-search { flex: 1 1 auto; min-width: 0; max-width: none; margin-left: 0; }
  #theme-toggle { flex-shrink: 0; }
}

/* ===== Ad slots (AdSense placeholders — swap contents for the real <ins> unit once approved) =====
   728x90/300x250 are FIXED-size desktop units — they don't shrink to fit and will overflow on
   phones if swapped in directly. Use AdSense's "Responsive" ad format
   (data-ad-format="auto" data-full-width-responsive="true") for these slots so the served
   creative matches the viewport instead of a fixed leaderboard/rectangle. The width:100% + child
   max-width below is a fallback guard, not a substitute for picking the responsive unit. */
.ad-slot {
  margin: 32px auto; padding: 16px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--muted); text-align: center; box-sizing: border-box; width: 100%;
}
.ad-slot > * { max-width: 100%; }
.ad-slot__label { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
.ad-slot__size { font-size: 12px; font-family: var(--font-mono); }
.ad-slot--leaderboard { min-height: 90px; max-width: 728px; }
.ad-slot--rectangle { min-height: 250px; max-width: 336px; }
.ad-slot--banner { min-height: 100px; max-width: 100%; }

.consent-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--card); border-top: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.consent-banner p { margin: 0; font-size: 14px; color: var(--muted); }
.consent-banner a { color: var(--accent-strong); }
.consent-banner__actions { display: flex; gap: 8px; flex-shrink: 0; }

.result-panel__header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 6px;
}
.result-panel.is-fullscreen {
  display: flex; flex-direction: column; padding: 20px; background: var(--bg);
}
.result-panel.is-fullscreen .result-panel__header { flex: 0 0 auto; margin-bottom: 12px; }
.result-panel.is-fullscreen textarea,
.result-panel.is-fullscreen .json-tree,
.result-panel.is-fullscreen .code-highlight {
  flex: 1 1 auto; width: 100%; height: auto; max-height: none;
  resize: none !important; /* the textarea sets resize:vertical inline; only !important can win over that */
}

.json-tree {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); font-family: var(--font-mono); font-size: 14px;
  overflow: auto; height: 220px; resize: vertical;
}
.json-tree .json-formatter-row { font-family: var(--font-mono); }

/* json-formatter-js (vendor/json-formatter.min.js) self-injects its own <style>
   after this stylesheet loads, so overrides here are scoped under .json-tree
   to out-specificity it rather than relying on source order. */
.json-tree .json-formatter-row, .json-tree .json-formatter-row a, .json-tree .json-formatter-row a:hover { color: var(--text); text-decoration: none; }
.json-tree .json-formatter-row .json-formatter-string, .json-tree .json-formatter-row .json-formatter-stringifiable { color: #2a9d5c; white-space: pre; word-wrap: break-word; }
.json-tree .json-formatter-row .json-formatter-number { color: #2b6cb0; }
.json-tree .json-formatter-row .json-formatter-boolean { color: #c0392b; }
.json-tree .json-formatter-row .json-formatter-null, .json-tree .json-formatter-row .json-formatter-undefined { color: #a0682a; }
.json-tree .json-formatter-row .json-formatter-bracket { color: var(--muted); }
.json-tree .json-formatter-row .json-formatter-key { color: var(--accent-strong); padding-right: 0.2rem; }
.json-tree .json-formatter-row .json-formatter-toggler-link { cursor: pointer; }
.json-tree .json-formatter-row > a > .json-formatter-preview-text { color: var(--muted); }
.json-tree .json-formatter-dark.json-formatter-row .json-formatter-string, .json-tree .json-formatter-dark.json-formatter-row .json-formatter-stringifiable { color: #6ee7a8; }
.json-tree .json-formatter-dark.json-formatter-row .json-formatter-number { color: #7ec2ff; }
.json-tree .json-formatter-dark.json-formatter-row .json-formatter-boolean { color: #ff8a7a; }
.json-tree .json-formatter-dark.json-formatter-row .json-formatter-null, .json-tree .json-formatter-dark.json-formatter-row .json-formatter-undefined { color: #eec97d; }

/* Prism.js (vendor/prism.min.js) — highlighted output uses tokens we color
   ourselves rather than one of Prism's bundled themes, so it matches the
   .json-tree palette above and stays in sync with light/dark mode. */
.code-highlight {
  margin: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-family: var(--font-mono); font-size: 13px;
  line-height: 1.5; overflow: auto; height: 220px; resize: vertical; white-space: pre;
}
.code-highlight code { font-family: var(--font-mono); white-space: pre; }
.code-highlight .token.comment, .code-highlight .token.prolog, .code-highlight .token.doctype, .code-highlight .token.cdata { color: var(--muted); }
.code-highlight .token.punctuation { color: var(--muted); }
.code-highlight .token.property, .code-highlight .token.tag, .code-highlight .token.boolean, .code-highlight .token.number, .code-highlight .token.constant, .code-highlight .token.symbol, .code-highlight .token.deleted { color: #2b6cb0; }
.code-highlight .token.selector, .code-highlight .token.attr-name, .code-highlight .token.string, .code-highlight .token.char, .code-highlight .token.builtin, .code-highlight .token.inserted { color: #2a9d5c; }
.code-highlight .token.operator, .code-highlight .token.entity, .code-highlight .token.url { color: var(--text); }
.code-highlight .token.atrule, .code-highlight .token.attr-value, .code-highlight .token.keyword { color: #a0682a; }
.code-highlight .token.function, .code-highlight .token.class-name { color: var(--accent-strong); }
.code-highlight .token.regex, .code-highlight .token.important, .code-highlight .token.variable { color: #c0392b; }
.code-highlight .token.important, .code-highlight .token.bold { font-weight: 700; }
.code-highlight .token.italic { font-style: italic; }
html[data-theme="dark"] .code-highlight .token.property, html[data-theme="dark"] .code-highlight .token.tag, html[data-theme="dark"] .code-highlight .token.boolean, html[data-theme="dark"] .code-highlight .token.number, html[data-theme="dark"] .code-highlight .token.constant, html[data-theme="dark"] .code-highlight .token.symbol, html[data-theme="dark"] .code-highlight .token.deleted { color: #7ec2ff; }
html[data-theme="dark"] .code-highlight .token.selector, html[data-theme="dark"] .code-highlight .token.attr-name, html[data-theme="dark"] .code-highlight .token.string, html[data-theme="dark"] .code-highlight .token.char, html[data-theme="dark"] .code-highlight .token.builtin, html[data-theme="dark"] .code-highlight .token.inserted { color: #6ee7a8; }
html[data-theme="dark"] .code-highlight .token.atrule, html[data-theme="dark"] .code-highlight .token.attr-value, html[data-theme="dark"] .code-highlight .token.keyword { color: #eec97d; }
html[data-theme="dark"] .code-highlight .token.regex, html[data-theme="dark"] .code-highlight .token.important, html[data-theme="dark"] .code-highlight .token.variable { color: #ff8a7a; }

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