/* ===== Fonts (self-hosted, SIL Open Font License) ===== */
@font-face { font-family: "Bricolage Grotesque"; src: url("/assets/fonts/bricolage-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("/assets/fonts/bricolage-800.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }

/* ===== Tokens ===== */
:root {
  --ink: #0A2240;
  --graphite: #56617A;
  --paper: #F6F7F9;
  --sheet: #FFFFFF;
  --line: #D8DDE6;
  --blue: #0A5FCC;
  --blue-dark: #054FB0;
  --marker: #FFE45C;
  --add: #E3F4E7;
  --add-ink: #1C6B34;
  --del: #FCE8E6;
  --del-ink: #A12A1E;
  --radius-s: 6px;
  --radius-m: 10px;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--body);
}
::selection { background: var(--marker); color: var(--ink); }
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--blue-dark); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
img { max-width: 100%; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.site-head { background: var(--sheet); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 76px; gap: 16px; }
.logo {
  font: 800 1.35rem/1 var(--display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.logo { display: block; line-height: 0; }
.logo img { display: block; height: 56px; width: auto; }
@media (max-width: 720px) { .logo img { height: 46px; } }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 22px; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 4px; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 12px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 76px; background: var(--sheet); border-bottom: 1px solid var(--line); z-index: 10; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; padding: 8px 20px 16px; }
  .site-nav li a { display: block; padding: 10px 0; }
  .site-head { position: relative; }
}

/* ===== Page heading ===== */
.crumbs { font-size: 0.88rem; color: var(--graphite); margin: 22px 0 6px; }
.crumbs a { color: var(--graphite); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0 0 8px; font-weight: 800; }
.lead { font-size: 1.1rem; color: var(--graphite); margin: 0 0 22px; max-width: 70ch; }

/* ===== Workspace ===== */
.workspace {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px;
}
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 14px; }
.controls:empty { display: none; }
.control-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 600 0.9rem/1 var(--body);
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--marker); border-color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 0.93rem; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field input[type="text"], .field input[type="number"] {
  font: inherit; font-size: 0.95rem;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 9px 11px; color: var(--ink); background: var(--sheet);
}
.field.narrow { flex: 0 0 110px; }

.panes { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .panes.two { grid-template-columns: 1fr 1fr; } }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane > label { font-weight: 700; font-size: 0.92rem; margin-bottom: 6px; }
.pane textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  font: 16px/1.55 var(--body);
  color: var(--ink);
  background: #FBFCFD;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 12px 14px;
}
@media (max-width: 899px) { .pane textarea { min-height: 170px; } }
.pane textarea.mono { font-family: var(--mono); font-size: 14px; }
.pane textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(10, 95, 204, 0.15); }
.pane textarea[readonly] { background: #F3F5F8; }
.pane-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.stats { font-size: 0.83rem; color: var(--graphite); margin-right: auto; }
.note { font-size: 0.88rem; color: var(--ink); width: 100%; }
.note:empty { display: none; }
.note.error { color: var(--del-ink); }

.btn {
  font: 600 0.9rem/1 var(--body);
  border: 1px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: 9px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.privacy-note { font-size: 0.85rem; color: var(--graphite); margin: 10px 0 0; }

/* Diff output */
.diff-out {
  font: 14px/1.5 var(--mono);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: #FBFCFD;
  min-height: 120px;
  max-height: 600px;
  overflow: auto;
}
.diff-out:empty::before { content: "Paste text into both boxes to see the differences."; display: block; padding: 14px; color: var(--graphite); font-family: var(--body); }
.dl { display: flex; white-space: pre-wrap; word-break: break-word; }
.dl .sign { flex: 0 0 28px; text-align: center; color: var(--graphite); user-select: none; }
.dl .lt { flex: 1; padding-right: 10px; }
.dl.add { background: var(--add); }
.dl.add .sign { color: var(--add-ink); font-weight: 700; }
.dl.del { background: var(--del); }
.dl.del .sign { color: var(--del-ink); font-weight: 700; }
.dl.skip { color: var(--graphite); font-style: italic; font-family: var(--body); padding: 4px 28px; }

/* ===== Ads ===== */
.ad-wrap { margin: 28px 0; min-height: 280px; display: flex; justify-content: center; }

/* ===== Content ===== */
.page-grid { display: grid; grid-template-columns: 1fr; gap: 40px; margin: 40px 0 60px; }
@media (min-width: 980px) { .page-grid { grid-template-columns: minmax(0, 1fr) 300px; } }
.prose { max-width: 72ch; }
.prose h2 { font-size: 1.55rem; margin: 2em 0 0.5em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.15rem; margin: 1.5em 0 0.4em; }
.prose p, .prose li { color: #2A3547; }
.prose code, .prose kbd { font-family: var(--mono); font-size: 0.88em; background: #EDF0F5; padding: 1px 5px; border-radius: 4px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.95rem; margin: 1em 0; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; border-bottom: 1px solid var(--line); padding: 8px 12px 8px 0; vertical-align: top; }
.prose th { font-weight: 700; }
.faq details { border-top: 1px solid var(--line); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { font-weight: 700; cursor: pointer; list-style-position: outside; }
.faq details p { margin: 10px 0 0; }

.related { align-self: start; position: sticky; top: 20px; }
.related h2 { font-size: 1.1rem; margin: 0 0 10px; }
.related ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.related li { border-bottom: 1px solid var(--line); }
.related a { display: block; padding: 11px 0; text-decoration: none; color: var(--ink); font-weight: 600; }
.related a:hover { color: var(--blue); }
.related small { display: block; font-weight: 400; color: var(--graphite); font-size: 0.83rem; }
@media (max-width: 979px) { .related { position: static; } }

/* ===== Home & hubs ===== */
.home-hero { padding: 56px 0 28px; max-width: 760px; }
.home-hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); letter-spacing: -0.03em; }
.home-hero p { font-size: 1.15rem; color: var(--graphite); margin: 0 0 24px; }
.finder { position: relative; max-width: 560px; }
.finder label { position: absolute; left: -9999px; }
.finder input {
  width: 100%;
  font: 500 1.1rem var(--body);
  padding: 15px 18px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-m);
  background: var(--sheet);
  color: var(--ink);
}
.finder input:focus { outline: none; box-shadow: 0 0 0 4px var(--marker); }
.tool-group { margin: 44px 0; }
.tool-group h2 { font-size: 1.5rem; margin: 0 0 4px; }
.tool-group h2 a { color: var(--ink); text-decoration: none; }
.tool-group h2 a:hover { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 4px; }
.tool-group > p { color: var(--graphite); margin: 0 0 16px; }
.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tool-list li { display: flex; }
.tool-list a {
  flex: 1;
  display: block;
  padding: 16px 18px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tool-list a strong { display: block; font-size: 1.02rem; margin-bottom: 4px; }
.tool-list a span { display: block; font-size: 0.9rem; line-height: 1.5; color: var(--graphite); }
.tool-list a:hover, .tool-list a:focus-visible { border-color: var(--ink); box-shadow: inset 0 -4px 0 var(--marker); }
.tool-list a:hover strong { color: var(--blue); }
.tool-list li[hidden] { display: none; }
.no-match { color: var(--graphite); display: none; }
.hub-intro { max-width: 72ch; }

/* ===== Footer ===== */
.site-foot { background: var(--sheet); border-top: 1px solid var(--line); padding: 44px 0 28px; font-size: 0.92rem; color: var(--graphite); }
.site-foot .wrap { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 760px) { .site-foot .wrap { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.foot-brand p { margin: 12px 0 0; max-width: 34ch; }
.foot-logo { display: inline-block; line-height: 0; }
.foot-col h2 { font: 700 0.95rem/1.2 var(--display); color: var(--ink); margin: 4px 0 10px; letter-spacing: 0; }
.foot-col ul { list-style: none; margin: 0; padding: 0; }
.foot-col li { margin: 0 0 7px; }
.site-foot a { color: var(--graphite); text-decoration: none; }
.site-foot a:hover { color: var(--blue); text-decoration: underline; }
.foot-copy { grid-column: 1 / -1; margin: 8px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 0.85rem; }

/* ===== Info pages, dates, misc ===== */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius-s); font-weight: 600; }
.skip-link:focus { top: 12px; color: #fff; }
.info-page { margin: 0 0 64px; }
.info-page .prose { margin-top: 8px; }
.contact-email { font: 700 1.3rem/1.3 var(--display); }
.updated { margin-top: 28px; font-size: 0.88rem; color: var(--graphite); }
.plain-links { padding-left: 20px; }
.plain-links li { margin: 4px 0; }
.home-about { margin-top: 8px; }

/* ===== Counters ===== */
.field input[type="number"]::placeholder { color: #8A93A6; }
.count-layout { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) { .count-layout { grid-template-columns: minmax(0, 1.6fr) minmax(290px, 1fr); } }
.count-layout .pane textarea { min-height: 360px; }
@media (max-width: 899px) { .count-layout .pane textarea { min-height: 200px; } }
.tally { min-width: 0; }
@media (min-width: 900px) { .tally { border-left: 1px solid var(--line); padding-left: 22px; } }
@media (max-width: 899px) { .tally { border-top: 1px solid var(--line); padding-top: 16px; } }
.tally-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 2px 0 14px; }
.tally-num {
  font: 800 clamp(2.8rem, 7vw, 4.2rem)/1 var(--display);
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(transparent 62%, var(--marker) 62%, var(--marker) 90%, transparent 90%);
  padding: 0 4px;
  margin-left: -4px;
}
.tally-num.is-time { font-size: clamp(2rem, 5vw, 2.7rem); }
.tally-label { font-weight: 600; color: var(--graphite); }
.tally-grid { margin: 0; border-top: 1px solid var(--line); }
.tally-grid div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.tally-grid dt { color: var(--graphite); }
.tally-grid dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tally-sub { font-size: 1rem; margin: 20px 0 8px; }
.tally-list { margin: 0; padding-left: 20px; font-size: 0.88rem; }
.tally-list li { margin-bottom: 8px; }
.tally-list span { display: block; color: #2A3547; }
.tally-list b { font-weight: 600; color: var(--graphite); font-size: 0.82rem; }
.meter { margin: 0 0 16px; }
.meter-bar { height: 8px; background: #E6EAF0; border-radius: 99px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.meter p { margin: 6px 0 0; font-size: 0.88rem; font-weight: 600; }
.meter.over .meter-bar span { background: var(--del-ink); }
.meter.over p { color: var(--del-ink); }

/* Analyzer reports (keyword density, word frequency) */
.pane textarea.short { min-height: 220px; }
.report { margin-top: 18px; }
.report-sum { margin: 0 0 10px; font-size: 0.93rem; color: var(--graphite); }
.report-focus { margin: 0 0 14px; padding: 10px 14px; background: #FFF8CC; border-left: 4px solid var(--marker); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.report-empty { color: var(--graphite); margin: 0; }
.table-scroll { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.table-scroll.tall { max-height: 640px; }
.report table { border-collapse: collapse; width: 100%; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.report th, .report td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.report th { position: sticky; top: 0; background: var(--sheet); font-size: 0.85rem; box-shadow: 0 1px 0 var(--line); }
.report td.r, .report th.r { text-align: right; }
.report td:first-child { color: var(--graphite); width: 3.5em; }
.report tbody tr:hover { background: #FBFCFD; }
.bar-cell { width: 28%; }
@media (max-width: 600px) { .bar-cell { display: none; } }
.bar { display: block; height: 10px; background: var(--marker); border: 1px solid #E0C63A; border-radius: 2px; }

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

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.field.num { flex: 0 0 auto; }
.field.num input { width: 150px; }
.control-row .field { max-width: 520px; }

/* ===== Status / redirect checker ===== */
.ctl-label { font-weight: 700; font-size: 0.92rem; }
.pane .btn:disabled { opacity: 0.6; cursor: progress; }
.sc-summary { margin: 16px 0 10px; font-weight: 600; }
.sc-summary:empty { display: none; }
.sc-results { display: grid; gap: 12px; }
.sc-item { border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius-s); padding: 14px 16px; background: #FBFCFD; min-width: 0; }
.sc-item.is-good { border-left-color: var(--add-ink); }
.sc-item.is-warn { border-left-color: #C98A00; }
.sc-item.is-bad { border-left-color: var(--del-ink); }
.sc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.sc-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.sc-chain .arrow { color: var(--graphite); padding: 0 2px; }
.sc-title { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; }
.sc-url { font-family: var(--mono); font-size: 0.88rem; overflow-wrap: anywhere; }
.sc-final { font-size: 0.85rem; color: var(--graphite); overflow-wrap: anywhere; }
.sc-time { font-size: 0.85rem; color: var(--graphite); white-space: nowrap; }
.badge { display: inline-block; min-width: 42px; text-align: center; font: 700 0.85rem/1 var(--body); padding: 6px 8px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.badge.s2 { background: var(--add); color: var(--add-ink); }
.badge.s3 { background: #FFF1C2; color: #7A5200; }
.badge.s4 { background: var(--del); color: var(--del-ink); }
.badge.s0 { background: #E6EAF0; color: var(--graphite); }
.sc-notes { list-style: none; margin: 12px 0 0; padding: 0; font-size: 0.92rem; }
.sc-notes li { padding: 3px 0 3px 22px; position: relative; }
.sc-notes li::before { position: absolute; left: 0; top: 3px; font-weight: 800; }
.sc-notes .n-good::before { content: "✓"; color: var(--add-ink); }
.sc-notes .n-warn::before { content: "!"; color: #9A6700; left: 5px; }
.sc-notes .n-bad::before { content: "✕"; color: var(--del-ink); }
.sc-notes .n-info::before { content: "i"; color: var(--blue); left: 5px; font-style: italic; }
.sc-steps { margin: 12px 0 0; padding-left: 22px; font-size: 0.9rem; }
.sc-steps li { margin: 0 0 8px; }
.sc-steps .badge { min-width: 38px; padding: 4px 6px; font-size: 0.8rem; }
.sc-meta { color: var(--graphite); font-size: 0.85rem; }
.sc-steps details { margin-top: 6px; }
.sc-steps summary { cursor: pointer; font-size: 0.85rem; color: var(--blue); }
.sc-steps table { border-collapse: collapse; margin-top: 6px; font-size: 0.82rem; width: 100%; display: block; overflow-x: auto; }
.sc-steps th, .sc-steps td { text-align: left; vertical-align: top; padding: 4px 10px 4px 0; border-bottom: 1px solid var(--line); }
.sc-steps th { white-space: nowrap; font-weight: 600; }
.sc-steps td { font-family: var(--mono); overflow-wrap: anywhere; }
#sc-export { margin-top: 12px; justify-content: flex-end; }
#sc-export[hidden] { display: none; }
