:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --text: #13201d;
  --muted: #5a6763;
  --border: #e0e6e3;
  --accent: #0f766e;
  --accent-2: #0e5f8a;
  --accent-soft: #e2f3f0;
  --link: #0d6b63;
  --focus: #0d6b63;
  --add-bg: #dcf5e6; --add-text: #0b5a2f;
  --del-bg: #fde2e2; --del-text: #8f1d1d;
  --ok: #0b7a4f; --bad: #b42318;
  --shadow: 0 10px 30px -14px rgba(20, 50, 45, .2);
  --radius: 16px;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1211; --surface: #141c1b; --surface-2: #1b2524; --text: #e9f1ef; --muted: #9aaba7; --border: #283533;
    --accent-soft: #143430; --link: #5fd3c4; --focus: #5fd3c4; --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
    --add-bg: #12392a; --add-text: #8fe8b5; --del-bg: #431c1c; --del-text: #ffb3b3; --ok: #3fd19a; --bad: #ff8a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1211; --surface: #141c1b; --surface-2: #1b2524; --text: #e9f1ef; --muted: #9aaba7; --border: #283533;
  --accent-soft: #143430; --link: #5fd3c4; --focus: #5fd3c4; --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  --add-bg: #12392a; --add-text: #8fe8b5; --del-bg: #431c1c; --del-text: #ffb3b3; --ok: #3fd19a; --bad: #ff8a80; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
[hidden] { display: none !important; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 62px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 800; letter-spacing: -.04em; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 500; font-size: 15px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-block; margin-left: auto; }
  .nav { display: none; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; }
  .nav.open { display: flex; }
}

.page-head { padding: 32px 0 16px; }
.page-head h1 { font-size: clamp(28px, 4.5vw, 40px); letter-spacing: -.03em; margin: 0 0 6px; line-height: 1.15; }
.page-head p { color: var(--muted); font-size: 18px; margin: 0; max-width: 720px; }

/* Cards & tool layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.tool { display: grid; gap: 16px; margin-bottom: 28px; }
.tool > *, .split > * { min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.split.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .split, .split.even { grid-template-columns: minmax(0, 1fr); } }

.io { display: flex; flex-direction: column; overflow: hidden; }
.io-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.io-title { font-weight: 700; font-size: 15px; }
.io-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.io-foot { padding: 8px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); min-height: 38px; }
.io-foot:empty::before { content: "\00a0"; }
textarea.text-in, textarea.text-out { display: block; width: 100%; min-height: 280px; resize: vertical; border: 0; padding: 16px 18px; font: inherit; font-size: 16px; line-height: 1.65; background: var(--surface); color: var(--text); }
textarea.text-in:focus, textarea.text-out:focus { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.split textarea.text-in { min-height: 420px; }
textarea.short { min-height: 240px !important; font-family: var(--mono); font-size: 14px; }
textarea.text-out { background: var(--surface-2); min-height: 220px; }
[data-tool="slug"] textarea, [data-tool="sort"] textarea, [data-tool="duplicates"] textarea { font-family: var(--mono); font-size: 14px; }

/* Options */
.options { display: grid; gap: 14px; }
.opt { display: flex; flex-direction: column; gap: 6px; }
.opt.grow { flex: 1 1 220px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; }
.lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.checks { flex-direction: row; flex-wrap: wrap; gap: 8px 20px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--border); background: var(--surface); border-radius: 10px; padding: 7px 12px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500; color: var(--text); }
.chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 650; }
:root[data-theme="dark"] .chip[aria-pressed="true"] { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[aria-pressed="true"] { color: var(--link); } }
input[type="text"], input[type="number"], select { font: inherit; font-size: 15px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0; }
input[type="number"] { width: 140px; }
.opt.grow input { width: 100%; }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 11px 16px; border-radius: 12px; font: inherit; font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--grad); color: #fff; border: 0; }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }

/* Stats */
.stats-card { display: grid; gap: 16px; position: sticky; top: 78px; }
@media (max-width: 900px) { .stats-card { position: static; } }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .stat-grid.four { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat.big .v { font-size: 32px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-list { margin: 0; display: grid; gap: 0; }
.stat-list div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.stat-list div:last-child { border-bottom: 0; }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.sel-note { margin: 0; font-size: 13px; background: var(--accent-soft); padding: 8px 10px; border-radius: 10px; }
.goal { display: grid; gap: 6px; }
.goal input { width: 100%; }
.meter { display: grid; gap: 4px; }
.meter-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .2s; }
.meter-bar span.over { background: var(--bad); }
.hint { color: var(--muted); font-size: 13.5px; margin: 0; }
.section-title { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.sub-title { font-size: 15px; margin: 18px 0 6px; }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* Keyword density */
.kd { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; }
.kd li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 14px; padding: 4px 0; }
.kd .w { font-weight: 600; overflow-wrap: anywhere; }
.kd .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.kd .bar { grid-column: 1 / -1; height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.kd .bar span { display: block; height: 100%; background: var(--accent); }

/* Limits */
.limits { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.limits li { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.limits .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.limits .name { font-weight: 650; }
.limits .num { font-variant-numeric: tabular-nums; color: var(--muted); }
.limits .num.over { color: var(--bad); font-weight: 700; }
.limits .num.ok { color: var(--ok); }

/* Frequency table */
.table-wrap { overflow-x: auto; margin-top: 10px; }
table.freq { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.freq th, .freq td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.freq th { color: var(--muted); font-weight: 600; font-size: 13px; }
.freq td:first-child { color: var(--muted); width: 48px; }
.freq td:nth-child(2) { font-weight: 600; overflow-wrap: anywhere; }
.freq td:nth-child(3), .freq th:nth-child(3) { text-align: right; width: 80px; }
.freq td:nth-child(4) { width: 34%; }
.share { display: flex; align-items: center; gap: 8px; }
.share .bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 40px; }
.share .bar span { display: block; height: 100%; background: var(--accent); }
.share small { width: 48px; text-align: right; color: var(--muted); }
#showAll { margin-top: 12px; }

/* Readability */
.read-hero { display: flex; gap: 18px; align-items: center; margin: 12px 0 16px; flex-wrap: wrap; }
.gauge { width: 140px; height: 140px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: conic-gradient(var(--g-color, var(--accent)) calc(var(--g, 0) * 1%), var(--surface-2) 0); position: relative; flex: none; }
.gauge::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.gauge > * { position: relative; }
.gauge .v { font-size: 34px; font-weight: 800; line-height: 1; }
.gauge .k { font-size: 11px; color: var(--muted); max-width: 90px; line-height: 1.3; margin-top: 4px; }
.read-label { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.read-hero > div:last-child { flex: 1 1 240px; }
.long-list { margin: 0; padding-left: 22px; display: grid; gap: 8px; font-size: 14.5px; }
.long-list li span { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-left: 4px; }

/* Diff */
.diff { font-family: var(--mono); font-size: 13.5px; line-height: 1.6; margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 12px; max-height: 640px; overflow: auto; }
.diff:empty { display: none; }
.diff .ln { display: block; padding: 0 12px 0 34px; position: relative; min-height: 1.6em; }
.diff .ln::before { position: absolute; left: 12px; color: var(--muted); }
.diff .ln.add { background: var(--add-bg); color: var(--add-text); }
.diff .ln.add::before { content: "+"; color: var(--add-text); }
.diff .ln.del { background: var(--del-bg); color: var(--del-text); }
.diff .ln.del::before { content: "−"; color: var(--del-text); }
.diff .ln.gap { color: var(--muted); font-style: italic; background: var(--surface-2); }
.diff.words { padding: 12px 14px; font-family: inherit; font-size: 15px; line-height: 1.75; }
.diff ins { background: var(--add-bg); color: var(--add-text); text-decoration: none; border-radius: 3px; }
.diff del { background: var(--del-bg); color: var(--del-text); border-radius: 3px; }

/* Tool grid */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin: 16px 0; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: var(--text); display: flex; gap: 12px; align-items: flex-start; transition: transform .15s, border-color .15s; }
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool-card .ti { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.tool-card strong { display: block; font-size: 15px; }
.tool-card small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; }

/* Article content */
.content { max-width: 780px; margin: 0 auto; }
.content h2 { font-size: 26px; letter-spacing: -.02em; margin: 36px 0 10px; }
.content h3 { font-size: 19px; margin: 24px 0 6px; }
.content p, .content li { color: color-mix(in srgb, var(--text) 86%, var(--muted)); }
.content .tool-grid { margin-left: 0; }
.content code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-variant-numeric: tabular-nums; }
.content th, .content td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.content th { font-size: 14px; color: var(--muted); }
.page-head code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 13px 16px 13px 56px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px 16px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 10px 0; }

.ad-slot { margin: 18px auto; text-align: center; min-height: 90px; max-width: 970px; }
.ad-placeholder { display: grid; place-items: center; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, transparent 10px, transparent 20px); border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }

.site-footer { margin-top: 56px; border-top: 1px solid var(--border); padding: 32px 0 40px; color: var(--muted); font-size: 14px; }
.foot-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 24px; margin-bottom: 16px; }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > :first-child { grid-column: 1 / -1; } }
.site-footer h4 { color: var(--text); margin: 0 0 8px; font-size: 14px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

.toast { position: fixed; left: 50%; bottom: 24px; width: max-content; max-width: min(520px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: center; transform: translateX(-50%) translateY(30px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 4px; }

@media (max-width: 600px) {
  .page-head { padding: 20px 0 10px; }
  .page-head p { font-size: 16px; }
  .split textarea.text-in { min-height: 260px; }
  textarea.text-in, textarea.text-out { min-height: 200px; }
  .chip, .btn-sm, .nav a { min-height: 40px; }
  .icon-btn { width: 44px; height: 44px; }
  .stat.big .v { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
