/* tools: shared styles. Dark by default; the header toggle sets data-theme on <html>. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #12161b;
  --raised: #1a2027;
  --line: #262d37;
  --text: #e7eaee;
  --muted: #8d96a3;
  --accent: #9aa8ff;
  --accent-ink: #0b0d10;
  --key: #9aa8ff;
  --str: #7ee0a8;
  --num: #f0b27a;
  --ok: #4ade80;
  --warn: #f0b27a;
  --bad: #f87171;
  --add-bg: #14391f;
  --add-ink: #86efac;
  --del-bg: #4c1d1d;
  --del-ink: #fca5a5;
  --chg-bg: #3b2d14;
  --focus: #9aa8ff;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --raised: #f0f2f5;
  --line: #dfe3e8;
  --text: #12161b;
  --muted: #566070;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --key: #4338ca;
  --str: #15803d;
  --num: #b45309;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --add-bg: #dcfce7;
  --add-ink: #14532d;
  --del-bg: #fee2e2;
  --del-ink: #7f1d1d;
  --chg-bg: #fef3c7;
  --focus: #4338ca;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono, code, textarea.code, .diff, .path {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wide { max-width: 1400px; }

/* header */
tools-header { display: block; border-bottom: 1px solid var(--line); }
.hdr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; min-height: 56px; }
.brand {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 500; font-size: 17px; color: var(--text); text-decoration: none;
}
.brand span { color: var(--accent); }
.hdr nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; flex: 1; }
.nav-group { display: flex; align-items: center; gap: 4px; }
.nav-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-right: 6px; }
.nav-sep { width: 1px; height: 16px; background: var(--line); }
.nav-link { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.nav-link:hover { color: var(--text); background: var(--raised); }
.nav-link[aria-current="page"] { color: var(--text); background: var(--raised); }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--raised); }
.icon-btn svg { display: block; }

/* footer */
footer { border-top: 1px solid var(--line); margin-top: 48px; }
.ftr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 24px; padding-bottom: 24px; font-size: 13px; color: var(--muted); }
.ftr a { color: var(--muted); }

/* landing */
.hero { padding: 72px 0 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted);
}
h1 { margin: 20px 0 0; max-width: 720px; font-size: clamp(34px, 6vw, 52px); line-height: 1.1; font-weight: 600; letter-spacing: -0.025em; }
.lede { margin: 16px 0 0; max-width: 560px; font-size: 18px; color: var(--muted); }
.group-title { margin: 48px 0 12px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 14px; padding: 20px; color: var(--text); text-decoration: none;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
a.card:hover { border-color: var(--accent); }
.card.soon { border-style: dashed; background: transparent; color: var(--muted); }
.card-top { display: flex; align-items: center; gap: 12px; }
.card-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--raised); display: inline-flex; align-items: center; justify-content: center; color: var(--accent); flex: none; }
.card.soon .card-icon { background: none; border: 1px dashed var(--line); color: var(--muted); }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; }
.card.soon h3 { color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.badge-soon { margin-left: auto; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; }
.preview {
  margin-top: auto; padding: 10px 12px; border-radius: 8px; background: var(--bg);
  border: 1px solid var(--line); font-size: 12.5px; line-height: 1.7; color: var(--muted);
}
.preview .k { color: var(--accent); }
.preview .ins { color: var(--ok); } .preview .chg { color: var(--warn); } .preview .del { color: var(--bad); }
.mk-del { background: var(--del-bg); color: var(--del-ink); border-radius: 3px; padding: 0 2px; }
.mk-add { background: var(--add-bg); color: var(--add-ink); border-radius: 3px; padding: 0 2px; }

/* tool pages */
.tool { padding-top: 24px; padding-bottom: 8px; }
.tool-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.tool-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.privacy { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.options {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin: 16px 0 12px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px;
}
.options label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.options input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.options .field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.options .note { margin-left: auto; font-size: 12.5px; color: var(--muted); }
input[type="text"], select, input[type="search"] {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; font: inherit; font-size: 14px; min-width: 0;
}
input.short { width: 7ch; }
input.mid { width: 14ch; }

.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pane { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.pane.drop { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); background: var(--raised); }
.pane-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-right: auto; }
textarea.code, pre.out {
  display: block; width: 100%; min-height: 340px; height: 52vh; margin: 0; padding: 12px 14px;
  border: 0; background: transparent; color: var(--text); font-size: 13px; line-height: 1.6;
  resize: vertical; tab-size: 2; white-space: pre; overflow: auto;
}
textarea.code { outline-offset: -2px; }
textarea.code::placeholder { color: var(--muted); opacity: 0.7; }
pre.out { white-space: pre; resize: none; }
.pane-foot { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); min-height: 32px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pane-foot.ok .dot { background: var(--ok); }
.pane-foot.ok { color: var(--ok); }
.pane-foot.err .dot { background: var(--bad); }
.pane-foot.err { color: var(--bad); }
.pane-foot .grow { margin-left: auto; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer; min-height: 30px; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.btn svg { display: block; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
}
.toast[hidden] { display: none; }

/* shared diff summary bar */
.summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 16px 0 12px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px;
}
.summary .count { font-weight: 600; }
.summary .count.same { color: var(--ok); }
.summary .stat-add { color: var(--ok); } .summary .stat-del { color: var(--bad); }
.summary .spacer { margin-left: auto; }
.filters { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.filter {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.filter[aria-pressed="true"] { background: var(--raised); color: var(--text); border-color: var(--muted); }
.error-box {
  margin: 16px 0; padding: 12px 14px; border: 1px solid var(--bad); border-radius: 10px;
  background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--text); font-size: 14px;
}

/* JSON compare results */
.changes { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.cgroup + .cgroup { border-top: 1px solid var(--line); }
.cgroup > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--raised); font-size: 13px;
}
.cgroup > summary::-webkit-details-marker { display: none; }
.cgroup > summary::before { content: "▸"; color: var(--muted); width: 1ch; }
.cgroup[open] > summary::before { content: "▾"; }
.cgroup .gkey { font-weight: 600; }
.cgroup .gcount { margin-left: auto; color: var(--muted); }
.crow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.badge { display: inline-block; min-width: 4.6em; text-align: center; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.added { background: var(--add-bg); color: var(--add-ink); }
.badge.removed { background: var(--del-bg); color: var(--del-ink); }
.badge.changed { background: var(--chg-bg); color: var(--warn); }
.path { word-break: break-all; }
.vals { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.val { padding: 1px 6px; border-radius: 4px; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; word-break: break-all; max-width: 100%; }
.val.l { background: var(--del-bg); color: var(--del-ink); }
.val.r { background: var(--add-bg); color: var(--add-ink); }
.crow .copy { margin-left: auto; }
.empty { padding: 28px 14px; text-align: center; color: var(--muted); }

/* text compare */
.diff { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow-x: auto; font-size: 13px; line-height: 1.6; }
.dline { display: grid; grid-template-columns: 1fr 1fr; min-width: 560px; }
.diff.unified .dline { grid-template-columns: 1fr; }
.dcell { display: grid; grid-template-columns: 4ch 1fr; gap: 10px; padding: 0 10px; min-width: 0; }
.dcell + .dcell { border-left: 1px solid var(--line); }
.dno { text-align: right; color: var(--muted); user-select: none; opacity: 0.8; }
.dtext { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.dcell.add { background: var(--add-bg); }
.dcell.remove { background: var(--del-bg); }
.dcell.empty { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--raised) 6px 7px); }
.dcell.add .dno, .dcell.remove .dno { color: inherit; }
.dtext mark { color: inherit; border-radius: 3px; padding: 0 1px; }
.dcell.add mark { background: color-mix(in srgb, var(--ok) 45%, transparent); }
.dcell.remove mark { background: color-mix(in srgb, var(--bad) 50%, transparent); }
.dline.current { box-shadow: inset 3px 0 0 var(--accent); }
.dsign { user-select: none; color: var(--muted); }
.gap {
  display: block; width: 100%; padding: 6px 14px; border: 0; border-block: 1px solid var(--line);
  background: var(--raised); color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left;
}
.gap:hover { color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 4px 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); }
.stepper { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }

@media (max-width: 800px) {
  .panes { grid-template-columns: 1fr; }
  textarea.code, pre.out { height: 38vh; min-height: 220px; }
  .options .note { margin-left: 0; width: 100%; }
  .hero { padding-top: 40px; }
  .btn, .icon-btn, .filter, .seg button { min-height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
  .nav-label { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .card, .nav-link { transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
}

tools-header { min-height: 57px; }
.dtext { min-height: 1.6em; }
.summary .stepper .btn { padding: 3px 8px; min-height: 28px; }
.panes.compact textarea.code { height: 30vh; min-height: 200px; }
@media (max-width: 800px) {
  .brand { margin-right: auto; }
  .hdr { gap: 4px 12px; padding-top: 8px; padding-bottom: 8px; }
  .hdr nav { order: 3; flex-basis: 100%; }
  .panes.compact textarea.code { height: 26vh; min-height: 160px; }
}
[hidden] { display: none !important; }

/* text length */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 14px; align-content: start; }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.big { grid-column: 1 / -1; }
.limit-bar { height: 6px; border-radius: 999px; background: var(--raised); overflow: hidden; margin-top: 8px; }
.limit-bar > span { display: block; height: 100%; background: var(--accent); }
.limit-bar.over > span { background: var(--bad); }
.stat.over .n { color: var(--bad); }
