/* ============ THEME TOKENS ============ */
:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f3f4f9;
  --border: #e4e6ef;
  --border-strong: #d5d8e6;
  --text: #171a2b;
  --text-soft: #4c5166;
  --text-faint: #7a7f95;

  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: #eef0fe;
  --accent: #8b5cf6;
  --success: #16a34a;
  --success-soft: #e7f6ec;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #d97706;

  --shadow-sm: 0 1px 2px rgba(23, 26, 43, 0.06);
  --shadow-md: 0 4px 16px rgba(23, 26, 43, 0.08);
  --shadow-lg: 0 16px 40px rgba(23, 26, 43, 0.14);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --header-h: 64px;
  --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.35);
  --speed: 150ms ease;
}

[data-theme="dark"] {
  --bg: #0e1020;
  --bg-soft: #161834;
  --surface: #171a33;
  --surface-2: #1e2142;
  --border: #262a4f;
  --border-strong: #343966;
  --text: #eef0fb;
  --text-soft: #b9bdd8;
  --text-faint: #8b90b3;

  --primary: #818cf8;
  --primary-strong: #a5b4fc;
  --primary-soft: #232755;
  --accent: #a78bfa;
  --success: #4ade80;
  --success-soft: #12301f;
  --danger: #f87171;
  --danger-soft: #3a1a1c;
  --warning: #fbbf24;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* ============ RESET / BASE ============ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

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

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; cursor: pointer; color: inherit; background: none; border: none; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 860px; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

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

/* ============ HEADER ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.brand-name em { font-style: normal; color: var(--primary); }

.main-nav { display: flex; gap: 2px; margin-left: 8px; flex: 1; }
.nav-link {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--speed), color var(--speed);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-strong); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-soft);
  transition: background var(--speed), border-color var(--speed), color var(--speed);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.toggle-label { min-width: 34px; }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ============ SECTIONS ============ */
.section { padding: 40px 0 56px; scroll-margin-top: var(--header-h); }
.hero { padding: 48px 0 40px; }

.hero-copy { max-width: 720px; margin: 0 auto 32px; text-align: center; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 14px;
}
.subtitle { font-size: 1.05rem; color: var(--text-soft); max-width: 620px; margin: 0 auto; }

.privacy-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 600;
  font-size: 13.5px;
}
.privacy-chip svg { width: 16px; height: 16px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  transition: transform var(--speed), background var(--speed), border-color var(--speed), color var(--speed), box-shadow var(--speed);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-strong); box-shadow: var(--shadow-md); }

.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-soft); }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

.link-btn { color: var(--primary-strong); font-weight: 600; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.link-btn:hover { text-decoration: underline; }

/* ============ EDITOR ============ */
.editor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 40px;
}
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-weight: 500;
  margin-right: 8px;
}
.save-indicator svg { width: 14px; height: 14px; }
.save-indicator.is-saving { color: var(--warning); }
.save-indicator.is-saved { color: var(--success); }

.editor-body { padding: 0; }
.editor {
  display: block;
  width: 100%;
  min-height: 320px;
  max-height: 68vh;
  resize: vertical;
  padding: 22px 24px;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
}
.editor:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--primary-soft); border-radius: 0; }
.editor::placeholder { color: var(--text-faint); }

.editor-statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-soft);
}
.editor-statusbar .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); }
.statusbar-right { margin-left: auto; display: flex; gap: 4px; }

/* ============ SECTION HEADS ============ */
.subsection { margin: 0 0 44px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 1.35rem; }
.section-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-head-toggle {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  padding: 4px 0;
  border-radius: var(--radius-sm);
}
.section-head-title { display: flex; align-items: center; gap: 10px; }
.section-head-toggle .chev { width: 20px; height: 20px; color: var(--text-faint); transition: transform var(--speed); }
.section-head-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.advanced-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.advanced-grid[hidden] { display: none; }

.section-title { text-align: center; margin: 0 auto 30px; max-width: 640px; }
.section-title h2 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); margin-bottom: 10px; }
.section-title p { color: var(--text-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-sub { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }

/* ============ STATS GRID ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-card[data-tone="green"] .stat-icon { background: var(--success-soft); color: var(--success); }
.stat-card[data-tone="purple"] .stat-icon { background: #f3e8ff; color: #9333ea; }
.stat-card[data-tone="amber"] .stat-icon { background: #fef3c7; color: #b45309; }
.stat-card[data-tone="rose"] .stat-icon { background: var(--danger-soft); color: var(--danger); }
[data-theme="dark"] .stat-card[data-tone="purple"] .stat-icon { background: #2b1e4a; color: #c084fc; }
[data-theme="dark"] .stat-card[data-tone="amber"] .stat-icon { background: #3a2c10; color: #fbbf24; }
.stat-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 12.5px; color: var(--text-soft); font-weight: 600; margin-top: 3px; }
.stat-hint { font-size: 11px; color: var(--text-faint); }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h3 { font-size: 1.02rem; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.seg-btn {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-faint);
  transition: background var(--speed), color var(--speed);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow-sm); }

/* ============ FREQUENCY ============ */
.freq-list { display: flex; flex-direction: column; gap: 7px; max-height: 380px; overflow: auto; }
.freq-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; }
.freq-rank { font-size: 12px; font-weight: 700; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.freq-word { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.freq-count { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.freq-bar {
  grid-column: 2 / 4;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}
.freq-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; }

/* ============ INSIGHTS ============ */
.insights { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 20px; }
.insight { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 1px dashed var(--border); }
.insight:last-child, .insight:nth-last-child(2):nth-child(odd) { border-bottom: none; }
.insight dt { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.insight dd { margin: 0; font-weight: 700; font-size: 13.5px; text-align: right; font-variant-numeric: tabular-nums; }

.empty-note { color: var(--text-faint); font-size: 13.5px; padding: 14px 0; text-align: center; }

/* ============ METRICS ============ */
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.metric-card { display: flex; align-items: center; gap: 14px; }
.metric-icon {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.metric-icon svg { width: 20px; height: 20px; }
.metric-label { font-size: 12px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.metric-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

.wpm-card { margin-top: 0; }
.wpm-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.wpm-label { font-weight: 700; font-size: 14px; }
.wpm-value {
  font-weight: 800;
  color: var(--primary-strong);
  background: var(--primary-soft);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(90deg, var(--primary) var(--pct, 50%), var(--surface-2) var(--pct, 50%));
  border-radius: 99px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
}
.wpm-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

/* readability meter */
.readability-meter { margin-top: 18px; }
.meter-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter-track-lg { height: 14px; }
.meter-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--success), var(--warning) 55%, var(--danger));
  transition: width 300ms ease;
  width: 0%;
}
.meter-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); font-weight: 600; }

/* ============ GOAL ============ */
.goal-card { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.field-inline { display: flex; align-items: center; gap: 8px; }
.goal-input-row { display: flex; gap: 8px; }
.goal-input-row input, .form-row input[type="text"], .form-row select, input[type="number"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.goal-input-row input:focus, .form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.goal-progress { min-width: 0; }
.goal-nums { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.goal-of { color: var(--text-faint); font-size: 13.5px; }
.goal-pct { margin-left: auto; }
.goal-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-soft); margin-top: 10px; }
.goal-card .link-btn { margin-top: 8px; }
.goal-card .link-btn[hidden] { display: none; }

/* ============ TOOLS ============ */
.tools-layout { display: grid; grid-template-columns: 200px 1fr; gap: 18px; }
.tools-nav-wrap { position: sticky; top: calc(var(--header-h) + 12px); align-self: start; }
.tools-nav { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-sm); }
.tools-nav h3 { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 10px 4px; }
.tool-nav-btn { text-align: left; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; color: var(--text-soft); transition: background var(--speed), color var(--speed); }
.tool-nav-btn:hover { background: var(--surface-2); color: var(--text); }
.tool-nav-btn.is-active { background: var(--primary-soft); color: var(--primary-strong); }

.tools-panel { min-width: 0; }
.tools-list { display: flex; flex-direction: column; gap: 10px; }
.tool-group { scroll-margin-top: calc(var(--header-h) + 16px); }
.tool-group.is-selected { }
.tool-group-title {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin: 14px 0 8px;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.tool-card.is-selected { border-color: var(--primary); box-shadow: var(--focus-ring); }
.tool-info { flex: 1; min-width: 0; }
.tool-name { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.tool-desc { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.tool-actions { display: flex; gap: 8px; flex: none; }

.tool-detail { margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tool-detail summary { padding: 14px 16px; font-weight: 700; font-size: 14.5px; cursor: pointer; list-style: none; }
.tool-detail summary::-webkit-details-marker { display: none; }
.tool-detail summary::after { content: "▾"; float: right; color: var(--text-faint); }
.tool-detail[open] summary::after { content: "▴"; }
.tool-detail-body { padding: 0 16px 16px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.form-row .field { flex: 1; min-width: 150px; }
.form-row input { width: 100%; }

.tool-preview {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.preview-head h3 { font-size: 14px; }
.preview-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.preview-note { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.preview-body {
  margin: 0;
  padding: 16px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
}

/* ============ COMPARE ============ */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.compare-card { padding: 14px; }
.compare-label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.compare-input {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
}
.compare-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.compare-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

.compare-results { animation: fadeUp 250ms ease; }
.compare-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.compare-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.compare-stat .metric-value { font-size: 1.2rem; }
.compare-stat .metric-label { margin-top: 2px; }

.compare-diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diff-card h3 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.diff-added h3 { color: var(--success); }
.diff-removed h3 { color: var(--danger); }
.diff-added h3::before, .diff-removed h3::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; display: inline-block;
}
.diff-added h3::before { background: var(--success); }
.diff-removed h3::before { background: var(--danger); }
.diff-list { display: flex; flex-wrap: wrap; gap: 6px; }
.diff-chip {
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.diff-added .diff-chip { background: var(--success-soft); color: var(--success); }
.diff-removed .diff-chip { background: var(--danger-soft); color: var(--danger); }
.diff-empty { color: var(--text-faint); font-size: 13px; font-style: italic; }

/* ============ KEYWORDS ============ */
.kw-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.kw-controls select { padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; font-size: 13px; }
.kw-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.kw-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow: auto; }
.kw-row { display: grid; grid-template-columns: 150px 60px 1fr; align-items: center; gap: 12px; }
.kw-word { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-count { font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.kw-bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.kw-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 300ms ease; }

/* ============ ABOUT ============ */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.about-card h3 { font-size: 1rem; margin-bottom: 8px; }
.about-card p { font-size: 14px; color: var(--text-soft); }

/* ============ FOOTER ============ */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding-top: 36px; }
.footer-inner { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-bottom: 28px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.footer-nav { display: flex; gap: 16px; }
.footer-nav a { color: var(--text-soft); font-weight: 600; font-size: 14px; }
.footer-nav a:hover { color: var(--text); text-decoration: none; }
.footer-privacy {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  background: var(--success-soft);
  padding: 8px 14px;
  border-radius: 999px;
}
.footer-privacy svg { width: 15px; height: 15px; }
.footer-bottom { border-top: 1px solid var(--border); padding: 18px 20px; font-size: 13px; color: var(--text-faint); }

/* ============ TOASTS ============ */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  font-weight: 600;
  font-size: 14px;
  animation: slideIn 220ms ease;
  max-width: 340px;
}
.toast::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--success); flex: none; }
.toast.toast-error::before { background: var(--danger); }
.toast.toast-info::before { background: var(--primary); }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(10, 12, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px;
  max-width: 420px;
  width: 100%;
  animation: fadeUp 200ms ease;
}
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--text-soft); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ============ ANIMATIONS ============ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

[hidden] { display: none !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 960px) {
  .advanced-grid { grid-template-columns: 1fr; }
  .tools-layout { grid-template-columns: 1fr; }
  .tools-nav-wrap { position: static; }
  .tools-nav { flex-direction: row; flex-wrap: wrap; }
  .tools-nav h3 { display: none; }
  .goal-card { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .main-nav { display: none; }
  .hero { padding: 36px 0 32px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .compare-grid { grid-template-columns: 1fr; }
  .compare-diff-grid { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .insights { grid-template-columns: 1fr; }
  .insight:nth-last-child(2):nth-child(odd) { border-bottom: 1px dashed var(--border); }
  .editor { min-height: 260px; font-size: 14px; padding: 16px; }
  .tool-card { flex-direction: column; align-items: stretch; }
  .tool-actions { justify-content: flex-end; }
  .footer-privacy { margin-left: 0; }
  .toasts { left: 20px; right: 20px; }
  .toast { max-width: none; }
  .header-inner { gap: 8px; }
  .toggle-label { display: none; }
  .icon-btn { padding: 9px 11px; }
}

/* Mobile nav fallback: show nav as scrollable row */
@media (max-width: 720px) {
  .main-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    gap: 4px;
    justify-content: space-around;
    z-index: 120;
  }
  .nav-link { font-size: 12.5px; padding: 8px 6px; flex: 1; text-align: center; }
  body { padding-bottom: 58px; }
}

/* ============ PRINT ============ */
@media print {
  .site-header, .site-footer, .toasts, .editor-toolbar, .modal-backdrop,
  .section-head-actions, .editor-statusbar, .btn, .seg, .wpm-card { display: none !important; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .section { padding: 8px 0; }
  .stat-card, .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .editor-card { box-shadow: none; }
}
