:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --border: #d9dad5;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --focus: #2f5d8a;

  --chg-bg: #fdf6dc;   --chg-edge: #d9b43a;
  --del-bg: #fcebea;   --del-edge: #c9514a;  --del-mark: #f3b9b4;
  --ins-bg: #e8f5ea;   --ins-edge: #3f9150;  --ins-mark: #a9dcb2;
  --empty-bg: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0,0,0,.035) 6px 12px);
  --yure-edge: #6b4fb8;  --yure-mark: #e4dcf7;

  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --surface: #1e2125;
    --text: #e3e5e8;
    --muted: #9aa1aa;
    --border: #353a40;
    --accent: #6f9fd0;
    --accent-text: #0f1215;
    --focus: #8ab4e0;
    --chg-bg: #3a3320;  --chg-edge: #c9a43a;
    --del-bg: #3d2322;  --del-edge: #d06a63;  --del-mark: #7a3531;
    --ins-bg: #1f3526;  --ins-edge: #5fae6f;  --ins-mark: #2f6a3b;
    --empty-bg: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.04) 6px 12px);
    --yure-edge: #b39cf0;  --yure-mark: #3f3363;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181b;
  --surface: #1e2125;
  --text: #e3e5e8;
  --muted: #9aa1aa;
  --border: #353a40;
  --accent: #6f9fd0;
  --accent-text: #0f1215;
  --focus: #8ab4e0;
  --chg-bg: #3a3320;  --chg-edge: #c9a43a;
  --del-bg: #3d2322;  --del-edge: #d06a63;  --del-mark: #7a3531;
  --ins-bg: #1f3526;  --ins-edge: #5fae6f;  --ins-mark: #2f6a3b;
  --empty-bg: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.04) 6px 12px);
  --yure-edge: #b39cf0;  --yure-mark: #3f3363;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.7 var(--sans);
}
main, .bar { max-width: 1400px; margin: 0 auto; padding: 0 24px; }

.bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding-top: 20px;
  padding-bottom: 12px;
}
h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .02em; }
.lead { margin: 0; color: var(--muted); font-size: 13px; grid-column: 1; }
.theme { grid-column: 2; grid-row: 1 / span 2; align-self: center; display: flex; gap: 0; }
.theme button { border-radius: 0; margin-left: -1px; font-size: 12px; padding: 4px 10px; }
.theme button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.theme button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.theme button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
kbd { font: 11px var(--mono); opacity: .75; margin-left: 6px; }

.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pane label { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
.count { font-weight: 400; color: var(--muted); font-size: 12px; }
textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  padding: 10px 12px;
  font: 13px/1.6 var(--sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0 20px; }
.note { margin: 0; color: var(--muted); font-size: 12px; }

.error {
  border: 1px solid var(--del-edge);
  background: var(--del-bg);
  padding: 10px 14px;
  border-radius: var(--radius);
}

.result { margin-bottom: 48px; }
.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.summary { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; margin-right: auto; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
}
.chip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.chip.chg { border-left-color: var(--chg-edge); }
.chip.del { border-left-color: var(--del-edge); }
.chip.ins { border-left-color: var(--ins-edge); }
.chip.total { border-left-color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.status { color: var(--muted); font-size: 12px; min-width: 1em; }

.grid-head, .row { display: grid; grid-template-columns: 76px 1fr 1fr; }
.grid-head { font-size: 12px; color: var(--muted); padding: 8px 0 4px; }
.grid-head span { padding: 0 10px; }

.rows { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.row { border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.rows.only-review .row.eq:not(.has-yure) { display: none; }

.no { padding: 8px 10px; font-size: 12px; color: var(--muted); border-left: 4px solid transparent; }
.no .num { display: block; font-variant-numeric: tabular-nums; }
.no .kind { display: block; font-size: 11px; }
.cell { padding: 8px 12px; border-left: 1px solid var(--border); min-width: 0; display: flex; align-items: flex-start; gap: 8px; }
.cell .text { flex: 1; min-width: 0; }
.copy-cell {
  flex: none;
  padding: 1px 8px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
.copy-cell:hover { color: var(--text); }
.copy-cell.done { color: var(--ins-edge); border-color: var(--ins-edge); }
.cell .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.cell.empty { background: var(--empty-bg); color: var(--muted); }
.side-label { display: none; }

.row.chg .no { border-left-color: var(--chg-edge); }
.row.chg .cell { background: var(--chg-bg); }
.row.del .no { border-left-color: var(--del-edge); }
.row.del .cell.old { background: var(--del-bg); }
.row.ins .no { border-left-color: var(--ins-edge); }
.row.ins .cell.new { background: var(--ins-bg); }
.row .kind { color: var(--muted); }
.row.chg .kind, .row.del .kind, .row.ins .kind { color: var(--text); font-weight: 600; }

del, ins { text-decoration: none; border-radius: 2px; padding: 0 1px; }
del { background: var(--del-mark); }
ins { background: var(--ins-mark); }
/* 全角半角・空白だけの違い（比較キー上は同じ） */
del.w, ins.w { background: var(--yure-mark); outline: 1px dashed var(--yure-edge); outline-offset: -1px; }

/* 表記揺れ */
mark.yure {
  background: transparent;
  color: inherit;
  text-decoration: underline wavy var(--yure-edge);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  text-decoration-skip-ink: none;
}
mark.yure.dict { text-decoration-style: solid; text-decoration-thickness: 2px; }
.yure-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--yure-edge);
  border: 1px solid var(--yure-edge);
}
.yure-notes {
  grid-column: 1 / -1;
  list-style: none;
  margin: 0;
  padding: 4px 12px 6px 90px;
  font-size: 12px;
  color: var(--yure-edge);
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
}
.chip.yure { border-left-color: var(--yure-edge); }

.dict { margin: 0 0 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.dict > summary { padding: 8px 12px; cursor: pointer; font-weight: 600; }
.dict-body { padding: 0 12px 12px; }
.dict-body .note { margin: 0 0 6px; }
.dict textarea { min-height: 120px; font-family: var(--mono); }
.dict code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 0 4px; border-radius: 3px; }

.empty-msg { margin: 0; padding: 16px; color: var(--muted); }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* 照合オプション（CTA/タグ/記号正規化） */
.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-right: auto; }
.opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; }

/* alt別レーン（照合対象外・一覧表示だけ） */
.alt-lane { margin: 0 0 48px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; }
.alt-lane h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.alt-lane h2 .note { font-weight: 400; }
.alt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.alt-col h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.alt-col ul { margin: 0; padding-left: 1.2em; font-size: 13px; }
.alt-col li { overflow-wrap: anywhere; margin: 2px 0; }
.alt-col li.empty-msg { list-style: none; padding: 0; margin-left: -1.2em; }

@media (max-width: 760px) {
  main, .bar { padding: 0 16px; }
  .bar { grid-template-columns: 1fr; padding-top: 16px; }
  .theme { grid-column: 1; grid-row: auto; justify-self: start; }
  .inputs { grid-template-columns: 1fr; }
  textarea { min-height: 160px; }
  .grid-head { display: none; }
  .row { grid-template-columns: 1fr; }
  .no { display: flex; gap: 10px; padding: 6px 12px; }
  .no .num, .no .kind { display: inline; }
  .cell { border-left: 0; border-top: 1px dashed var(--border); display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; }
  .side-label { display: block; font-size: 11px; color: var(--muted); padding-top: 2px; }
  .toolbar { position: static; }
  .yure-notes { padding-left: 12px; }
  .alt-grid { grid-template-columns: 1fr; }
}

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