/* TextScope — shared styles */
:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --border: #e3e7f0;
  --text: #101828;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-2: #0e7490;
  --accent-soft: #eef2ff;
  --good: #067647;
  --good-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --bad: #b42318;
  --bad-soft: #fef3f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 30px -14px rgba(16, 24, 40, .14);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a33;
  --surface-2: #1a2444;
  --border: #27324f;
  --text: #e7ecf5;
  --muted: #9aa5bd;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --accent-soft: #1d2750;
  --good: #34d399;
  --good-soft: #0d2b22;
  --warn: #fbbf24;
  --warn-soft: #2d2408;
  --bad: #f87171;
  --bad-soft: #33120f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -16px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { vertical-align: middle; }
.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 62px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand svg { display: block; }
.main-nav { display: flex; gap: 4px; margin-left: 6px; flex: 1; }
.main-nav a {
  color: var(--muted); font-size: 14.5px; font-weight: 500;
  padding: 7px 12px; border-radius: 9px;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.main-nav a.active { color: var(--accent); background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); }

/* Hero */
.hero { padding: 54px 0 26px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.15; margin: 0 0 14px; letter-spacing: -0.02em; }
.hero .lead { color: var(--muted); font-size: 17px; max-width: 660px; margin: 0 auto 8px; }
.badge-line { margin-bottom: 16px; }
.badge {
  display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 4px 12px; border-radius: 999px;
}

/* Tool card */
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow);
  padding: 22px; margin: 26px auto 0; max-width: 820px; text-align: left;
}
.tool-card.wide { max-width: 900px; }
.tool-area {
  width: 100%; min-height: 230px; resize: vertical;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.65;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.tool-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* Results */
.results { margin-top: 18px; display: grid; gap: 16px; }
.results[hidden] { display: none; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px;
}
.stat-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.stat-card .value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.stat-card .label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.section-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
}
.section-card h3 { margin: 0 0 12px; font-size: 16px; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .panels { grid-template-columns: 1fr; } }

/* Readability meter */
.meter-wrap { margin: 6px 0 14px; }
.meter {
  position: relative; height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, #dc2626 0%, #f59e0b 35%, #22c55e 65%, #16a34a 100%);
}
.meter .marker {
  position: absolute; top: -4px; width: 4px; height: 20px; border-radius: 4px;
  background: var(--text); transform: translateX(-50%);
  transition: left .25s ease;
}
.readability-big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.readability-label { font-weight: 600; color: var(--accent); }
.metric-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin-top: 4px; }
.metric-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.metric-row .k { color: var(--muted); }
.metric-row .v { font-weight: 600; text-align: right; }

/* Keyword list */
.kw-list { display: flex; flex-direction: column; gap: 8px; }
.kw-row { display: grid; grid-template-columns: 96px 1fr 56px; align-items: center; gap: 10px; font-size: 13.5px; }
.kw-word { font-family: var(--mono); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.kw-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.kw-pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.kw-empty, .empty-note { color: var(--muted); font-size: 14px; }

/* Checklist (headline page) */
.check-item {
  display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border);
  font-size: 14.5px; align-items: flex-start;
}
.check-item:last-child { border-bottom: 0; }
.check-item .ico { flex: none; width: 20px; text-align: center; font-size: 15px; }
.check-item .state { margin-left: auto; flex: none; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; }
.state.good { color: var(--good); background: var(--good-soft); }
.state.warn { color: var(--warn); background: var(--warn-soft); }
.state.bad { color: var(--bad); background: var(--bad-soft); }
.check-item p { margin: 0; }
.check-item .hint { color: var(--muted); font-size: 13px; }

/* SERP preview */
.serp { background: #fff; color: #1a0dab; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px 16px; }
[data-theme="dark"] .serp { background: #fff; color: #1a0dab; }
.serp .serp-title { font-size: 17px; line-height: 1.3; margin-bottom: 2px; word-break: break-word; }
.serp .serp-url { color: #006621; font-size: 13px; }
.serp .serp-url span { color: #4b5563; }

/* Inputs */
.input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type="range"] { accent-color: var(--accent); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.mini-input { width: 130px; }

/* Content sections */
.content { max-width: 820px; margin: 0 auto; padding: 44px 20px 10px; }
.content h2 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.01em; }
.content .sub { color: var(--muted); margin: 0 0 22px; }
.faq details {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 600; font-size: 15.5px; }
.faq details p { color: var(--muted); font-size: 14.5px; margin: 10px 0 2px; }

/* Tool links (cross links) */
.tool-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tool-link {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.tool-link:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); }
.tool-link .tl-name { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.tool-link .tl-desc { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 28px 0 34px; }
.footer-inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13.5px; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }
.footer-disclaimer { width: 100%; color: var(--muted); font-size: 12.5px; opacity: .85; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 99; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 404 */
.notfound { text-align: center; padding: 90px 20px; }
.notfound h1 { font-size: 60px; margin: 0 0 8px; }
.notfound p { color: var(--muted); }

@media (max-width: 640px) {
  .header-inner { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .main-nav { order: 3; width: 100%; margin-left: 0; }
  .main-nav a { flex: 1; text-align: center; padding: 8px 6px; }
  .hero { padding-top: 38px; }
  .tool-card { padding: 16px; margin-top: 18px; }
}
