:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef1f4;
  --border: #dfe3e8;
  --border-strong: #c7ccd4;
  --text: #111418;
  --text-muted: #5b6470;
  --accent: #0a7c5a;
  --accent-hover: #086a4d;
  --accent-soft: #e6f4ee;
  --danger: #b42318;
  --danger-soft: #fef0ee;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Header */
header.site {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.site .row {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand img { width: 28px; height: 28px; display: block; }
.brand .mono-brand { font-family: var(--mono); letter-spacing: -.5px; }
nav.primary { display: flex; gap: 22px; }
nav.primary a { color: var(--text-muted); font-size: 14px; font-weight: 500; }
nav.primary a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 640px) { nav.primary { display: none; } }

/* Hero */
.hero { padding: 48px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 14px; letter-spacing: -.02em; line-height: 1.1; font-weight: 800; }
.hero .lead { font-size: clamp(16px, 2.2vw, 19px); color: var(--text-muted); max-width: 640px; margin: 0 auto 16px; }
.hero .privacy-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent-soft); color: var(--accent-hover);
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.hero .privacy-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* Tool */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin: 28px 0;
}
.direction-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.direction-label {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--text-muted); letter-spacing: .3px;
}
.direction-label strong { color: var(--accent-hover); }
.mode-row { display: flex; align-items: center; gap: 10px; }
.mode-row label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
select#mode, button {
  font-family: var(--sans); font-size: 14px;
}
select#mode {
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); cursor: pointer; font-weight: 600;
}
select#mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.panes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 720px) { .panes { grid-template-columns: 1fr; } }

.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.pane-head .lab { font-size: 13px; font-weight: 700; color: var(--text); font-family: var(--mono); }
.pane-head .count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

textarea {
  width: 100%; min-height: 180px; resize: vertical;
  padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 15px; line-height: 1.5;
  box-shadow: inset 0 1px 2px rgba(16,24,40,.03);
}
textarea::placeholder { color: #9aa3af; }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea[readonly] { background: var(--surface-2); }

.controls {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;
  align-items: center;
}
button {
  cursor: pointer; border-radius: var(--radius-sm);
  padding: 9px 16px; font-weight: 600; border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--bg); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-status { font-size: 13px; color: var(--accent-hover); font-weight: 600; opacity: 0; transition: opacity .15s; }
.copy-status.show { opacity: 1; }
.copy-status.error { color: var(--danger); }

/* Examples */
.examples { margin: 8px 0 4px; }
.examples .ex-label { font-size: 13px; color: var(--text-muted); margin-right: 8px; }
.chip {
  display: inline-block; background: var(--bg); border: 1px solid var(--border-strong);
  padding: 5px 11px; border-radius: 999px; font-size: 13px; color: var(--text);
  cursor: pointer; margin: 4px 6px 4px 0; font-family: var(--mono);
  transition: background .12s, border-color .12s;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Content sections */
section.block { padding: 36px 0; border-top: 1px solid var(--border); }
section.block h2 { font-size: clamp(22px, 3vw, 28px); margin: 0 0 16px; letter-spacing: -.01em; }
section.block h3 { font-size: 17px; margin: 22px 0 8px; }
section.block p { margin: 0 0 12px; color: var(--text); }
section.block ul { margin: 8px 0 16px; padding-left: 22px; }
section.block li { margin-bottom: 7px; }
.muted { color: var(--text-muted); }
code { font-family: var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: .92em; }

/* Mapping table */
details.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
details.table-wrap summary { cursor: pointer; font-weight: 700; font-size: 16px; list-style: none; }
details.table-wrap summary::-webkit-details-marker { display: none; }
details.table-wrap summary::before { content: "▸ "; color: var(--accent); display: inline-block; transition: transform .15s; }
details.table-wrap[open] summary::before { content: "▾ "; }
.table-actions { display: flex; gap: 8px; align-items: center; margin: 14px 0 10px; flex-wrap: wrap; }
.table-actions .hint { font-size: 12px; color: var(--text-muted); }
table.mapping { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 14px; }
table.mapping th, table.mapping td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
table.mapping th { background: var(--surface-2); font-family: var(--sans); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
table.mapping td input {
  width: 100%; border: 1px solid transparent; background: transparent;
  font-family: var(--mono); font-size: 14px; padding: 3px 4px; border-radius: 4px; color: var(--text);
}
table.mapping td input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
table.mapping tr.conflict td input { background: var(--danger-soft); }
.rule-error {
  margin-top: 10px; padding: 9px 12px; background: var(--danger-soft);
  border: 1px solid #f5c6c0; color: var(--danger); border-radius: var(--radius-sm); font-size: 13px;
}
.rule-error:empty { display: none; }

/* FAQ */
details.faq { border-bottom: 1px solid var(--border); padding: 14px 0; }
details.faq summary { cursor: pointer; font-weight: 600; font-size: 16px; list-style: none; display: flex; gap: 8px; align-items: baseline; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before { content: "+"; color: var(--accent); font-weight: 700; font-size: 18px; }
details.faq[open] summary::before { content: "−"; }
details.faq .a { margin: 10px 0 4px; color: var(--text-muted); padding-left: 18px; }

/* Footer */
footer.site { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; margin-top: 24px; }
footer.site .row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
footer.site .meta { font-size: 13px; color: var(--text-muted); }
footer.site .links a { color: var(--text-muted); font-size: 13px; margin-left: 16px; }
footer.site .links a:hover { color: var(--text); }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff; padding: 8px 14px; z-index: 100; border-radius: 0 0 6px 0; }
.skip-link:focus { left: 0; }
