/* Text compare — r7 document workspace. Local styles only (no external fonts or assets). */
:root {
  color-scheme: light;
  --page: #F5F7F9;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --text: #18212F;
  --text-2: #546273;
  --border: #D7DEE6;
  --divider: #E6EBF0;
  --active: #174C86;
  --active-strong: #0F3863;
  --active-soft: #EEF5FC;
  --active-line: #C9DCF0;
  --del-bg: #FCECEC; --del-ink: #8F2631; --del-row: #FEF8F8;
  --ins-bg: #E9F5ED; --ins-ink: #185A39; --ins-row: #F6FBF7;
  --warn-bg: #FFF6DB; --warn-ink: #5C4300; --warn-line: #E3C463;
  --err-bg: #FCECEC; --err-ink: #8F2631;
  --focus: #1F6FEB;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --ctl: 40px;
}
:lang(ja) { --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", Meiryo, "Noto Sans CJK JP", sans-serif; }
:lang(ko) { --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans CJK KR", sans-serif; }
:lang(zh-Hans) { --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 26px; overflow-wrap: break-word; }
:lang(ko) { word-break: keep-all; }
textarea, .txt, .context, .clean-text, .phrase, .occ-text, .ch-phrase, .exact-text, .pv-pair { word-break: normal; }
a { color: var(--active); text-underline-offset: 0.18em; }
a:hover { color: var(--active-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4, h5 { margin: 0; color: var(--text); }
p { margin: 0 0 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { top: 8px; }
.hint { color: var(--text-2); font-size: 14px; line-height: 20px; }
.spacer { flex: 1 1 auto; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1440px; margin: 0 auto; padding: 0 32px; min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 16px; margin-right: auto; }
.brand:hover { color: var(--text); }
.brand-mark { width: 24px; height: 24px; flex: none; }
.site-nav ul, .lang-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.site-nav a, .lang-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; text-decoration: none; color: var(--text-2); font-size: 14px; font-weight: 600; }
.site-nav a:hover, .lang-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--active); }
.lang-nav a[aria-current="true"] { color: var(--active); }
.site-footer { color: var(--text-2); font-size: 12px; line-height: 18px; }
.footer-in { max-width: 1440px; margin: 0 auto; padding: 16px 32px 32px; }
.footer-in p { max-width: 900px; margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ctl); padding: 0 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; line-height: 20px; font-weight: 600;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { border-color: var(--text-2); }
.btn-primary { background: var(--active); border-color: var(--active); color: #fff; }
.btn-primary:hover { background: var(--active-strong); border-color: var(--active-strong); color: #fff; }
.btn-secondary { border-color: var(--active); color: var(--active); }
.btn-secondary:hover { background: var(--active-soft); border-color: var(--active-strong); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--active); }
.btn-quiet:hover { background: var(--active-soft); border-color: transparent; }
.btn-small { min-height: 32px; padding: 0 10px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Page */
.shell { max-width: 1440px; margin: 0 auto; padding: 24px 32px 40px; }
.intro { margin-bottom: 16px; }
.intro h1 { font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.01em; }
.intro .lead { margin: 4px 0 0; color: var(--text-2); }
.notice { margin: 0; padding: 10px 20px; font-size: 14px; line-height: 20px; border-bottom: 1px solid var(--divider); }
.notice-error { background: var(--err-bg); color: var(--err-ink); }
.notice-warn { background: var(--warn-bg); color: var(--warn-ink); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice-info { background: var(--active-soft); color: var(--text); }
.intro + noscript .notice, #unsupported { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }

/* One document surface */
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 52px; padding: 6px 16px; border-bottom: 1px solid var(--border); }
.menu { position: relative; }
.menu > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: var(--ctl); padding: 0 10px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--active); }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: "▾"; font-size: 12px; }
.menu > summary:hover { background: var(--active-soft); }
.menu-body { position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; width: min(420px, 86vw); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; box-shadow: 0 6px 18px rgb(24 33 47 / 0.12); font-size: 14px; line-height: 20px; }
.menu-body p { margin: 0 0 8px; }
.rule { border: 0; margin: 0; padding: 0; }
.rule legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
.choice { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.choice input { width: 18px; height: 18px; accent-color: var(--active); margin: 0; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-b { border-left: 1px solid var(--border); }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; min-height: 44px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--divider); }
.pane-head label { font-size: 14px; line-height: 20px; font-weight: 700; }
.pane-head .btn-small { margin-left: auto; }
.count { font-size: 12px; line-height: 18px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.count.over { color: var(--err-ink); font-weight: 700; }
textarea { font: inherit; color: var(--text); }
.pane textarea { display: block; width: 100%; height: 300px; min-height: 120px; resize: vertical; margin: 0; padding: 16px 20px; font-size: 16px; line-height: 26px; background: var(--surface); border: 0; border-radius: 0; tab-size: 4; }
.pane textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.pane textarea::placeholder { color: #6A7684; opacity: 1; }
.pane textarea[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--err-ink); }
.side-note:empty { display: none; }
.side-note { margin: 0; padding: 6px 20px; border-top: 1px solid var(--divider); }
.preview { margin: 12px 20px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); }
.preview-note { font-weight: 600; font-size: 14px; line-height: 20px; }
.preview-text { white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; max-height: 220px; overflow-y: auto; padding: 6px 8px; background: var(--surface); border: 1px solid var(--divider); border-radius: 4px; }
.preview-text.is-cut::after { content: " …"; color: var(--text-2); }
.input-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.btn-compare { min-width: 140px; }
.msgs .status { margin: 0; padding: 0 20px; font-size: 14px; line-height: 20px; }
.msgs .status:not(:empty) { padding: 10px 20px; border-top: 1px solid var(--divider); }
.status-error:not(:empty) { background: var(--err-bg); color: var(--err-ink); }
.status.busy::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border: 2px solid var(--active); border-right-color: transparent; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Result toolbar */
.bar-result { position: sticky; top: 0; z-index: 15; background: var(--surface); border-radius: 10px 10px 0 0; }
.sum { font-size: 14px; line-height: 20px; font-weight: 700; margin-right: 4px; }
.sum:focus { outline: none; }
.sum:focus-visible { outline: 2px solid var(--focus); }
.sum .sub { font-weight: 400; color: var(--text-2); }
.progress-text { font-size: 14px; line-height: 20px; color: var(--text-2); font-variant-numeric: tabular-nums; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--divider); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; line-height: 20px; font-weight: 600; min-height: 36px; padding: 0 12px; border: 0; background: var(--surface); color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--active); color: #fff; }
.take { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 320px; max-width: 90vw; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; box-shadow: 0 8px 24px rgb(24 33 47 / 0.14); }
.pop-note { font-size: 12px; line-height: 18px; color: var(--text-2); margin: 4px 8px 8px; }
.pop-item { display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; font: inherit; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); text-align: start; cursor: pointer; }
.pop-item:hover { background: var(--active-soft); }
.pop-item[disabled] { opacity: 0.45; cursor: not-allowed; }
.pop-main { color: var(--active); }
.pop-sep { height: 1px; background: var(--divider); margin: 6px 4px; }
.fallback { padding: 8px; border-top: 1px solid var(--divider); margin-top: 6px; }
.fallback label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); }
.fallback textarea { width: 100%; font-size: 14px; line-height: 20px; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.bar-status { flex-basis: 100%; margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ins-ink); }
.bar-status.status-error { color: var(--err-ink); }
.bar-status:empty { display: none; }

/* Find (literal) */
.find { padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.find label { display: block; font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: 4px; }
.watch-row { display: flex; gap: 8px; max-width: 560px; }
.watch-row input { flex: 1 1 auto; min-width: 0; min-height: var(--ctl); padding: 0 10px; font: inherit; color: var(--text); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.watch-row input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.find .hint { margin: 6px 0 0; font-size: 12px; line-height: 18px; }
.watch-msg { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--warn-ink); }
.watch-msg:empty { display: none; }
.watch-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.watch-list > .hint { grid-column: 1 / -1; }
.term { background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; padding: 8px 10px; }
.term-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 6px; }
.term-text { font-weight: 700; overflow-wrap: anywhere; }
.term-remove { grid-row: 1 / span 2; grid-column: 2; min-width: 40px; font-size: 18px; }
.term-status { justify-self: start; font-size: 12px; line-height: 18px; font-weight: 700; padding: 0 6px; border-radius: 4px; border: 1px solid currentColor; }
.st-both { color: var(--text-2); } .st-added { color: var(--ins-ink); } .st-removed { color: var(--del-ink); } .st-count { color: var(--warn-ink); } .st-none { color: var(--text-2); border-style: dashed; }
.term-counts { margin: 2px 0 4px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.occ h5 { font-size: 12px; line-height: 18px; color: var(--text-2); margin-top: 4px; }
.occ ul { list-style: none; margin: 0; padding: 0; }
.occ li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; font-size: 14px; line-height: 20px; }
.occ-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.occ mark { background: #FFE58F; color: var(--text); border-radius: 2px; }
.occ-jump { font: inherit; font-size: 12px; color: var(--active); background: none; border: 0; padding: 2px; text-decoration: underline; cursor: pointer; min-height: 24px; }
.occ-more { font-size: 12px; color: var(--text-2); margin: 0; }

/* Paired document canvas */
.work { display: grid; grid-template-columns: minmax(0, 1fr); }
.main-col { min-width: 0; }
.cols-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cols-head span { padding: 6px 20px 6px 56px; font-size: 12px; line-height: 18px; font-weight: 700; color: var(--text-2); }
.cols-head span + span { border-left: 1px solid var(--border); }
.canvas-banner { margin: 0; padding: 12px 20px; font-weight: 600; border-bottom: 1px solid var(--divider); background: var(--active-soft); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--divider); scroll-margin: 120px 0 90px; content-visibility: auto; contain-intrinsic-size: auto 43px; }
.row.is-selected { content-visibility: visible; }
.row:focus { outline: none; }
.row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cell { position: relative; min-width: 0; padding: 8px 20px 8px 56px; }
.cell-b { border-left: 1px solid var(--border); }
.gut { position: absolute; left: 0; top: 8px; width: 48px; display: flex; justify-content: flex-end; gap: 6px; padding-right: 8px; font-size: 12px; line-height: 26px; color: #8592A1; font-variant-numeric: tabular-nums; user-select: none; }
.glyph { width: 10px; text-align: center; font-weight: 700; font-size: 14px; }
.cell-a .glyph { color: var(--del-ink); }
.cell-b .glyph { color: var(--ins-ink); }
.txt { white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; min-height: 26px; }
.row:not(.is-changed) .txt { color: #2E3A4A; }
.row.is-changed { cursor: pointer; }
.row.is-changed .cell-a { background: var(--del-row); }
.row.is-changed .cell-b { background: var(--ins-row); }
.row.is-selected { cursor: default; box-shadow: inset 4px 0 0 var(--active); }
.row.is-selected .cell-a, .row.is-selected .cell-b { background: var(--active-soft); }
.empty-cell { display: inline-block; color: var(--text-2); font-size: 14px; font-style: italic; padding: 0 8px; border: 1px dashed var(--border); border-radius: 4px; }
del, ins { text-decoration-thickness: 2px; text-decoration-skip-ink: none; border-radius: 3px; padding: 1px 2px; }
del { background: var(--del-bg); color: var(--del-ink); text-decoration-line: line-through; }
ins { background: var(--ins-bg); color: var(--ins-ink); text-decoration-line: underline; text-underline-offset: 0.2em; }
del.cur, ins.cur { box-shadow: 0 0 0 2px currentColor; }
.caret { display: inline-block; width: 0; height: 0; margin: 0 2px; vertical-align: -4px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 7px solid var(--active); }
.ctx-hidden { text-decoration: underline dotted #8592A1; text-underline-offset: 0.25em; }
.wsmark { display: inline-block; font-size: 0.78em; line-height: 1.2; padding: 0 0.25em; margin: 0 0.05em; border: 1px dashed currentColor; border-radius: 3px; vertical-align: 0.05em; text-decoration: none; }
.cut { color: var(--text-2); }
.row-note { display: block; font-size: 12px; line-height: 18px; color: var(--text-2); font-style: italic; margin-bottom: 2px; white-space: normal; }
.run { border-bottom: 1px solid var(--divider); background: var(--surface-2); }
.run-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 36px; border: 0; background: transparent; font: inherit; font-size: 12px; line-height: 18px; color: var(--text-2); cursor: pointer; }
.run-show { color: var(--active); font-weight: 700; }
.run-btn:hover { background: var(--active-soft); }

/* Selected change: tools strip under its row */
.row-tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 10px 20px 10px 56px; background: var(--surface); border-top: 1px solid var(--active-line); }
.sel { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.sel-tag { font-size: 12px; line-height: 18px; font-weight: 700; color: var(--active); border: 1px solid var(--active); border-radius: 4px; padding: 0 6px; }
.sel-h { font-size: 14px; line-height: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sel-h:focus { outline: none; }
.sel-h:focus-visible { outline: 2px solid var(--focus); }
.sel-meta { font-size: 12px; line-height: 18px; color: var(--text-2); }
.kind { font-weight: 700; }
.kind-removed { color: var(--del-ink); } .kind-added { color: var(--ins-ink); } .kind-changed { color: var(--text); }
.state { font-size: 12px; line-height: 18px; font-weight: 700; color: var(--text-2); }
.state.is-done { color: var(--ins-ink); }
.state.is-done::before { content: "✓ "; }
.state.is-edited { color: var(--warn-ink); }
.phrase { flex-basis: 100%; order: 3; font-size: 16px; line-height: 26px; }
.phrase .ph-arrow { color: var(--text-2); }
.ph-empty { color: var(--text-2); }
.sel-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.exact { order: 4; flex-basis: 100%; }
.exact > summary { display: inline-flex; align-items: center; min-height: 32px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--active); }
.exact-head { font-size: 12px; color: var(--text-2); margin: 4px 0; }
.exact-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.exact-side { border: 1px solid var(--divider); border-radius: 6px; padding: 6px 10px; background: var(--surface-2); min-width: 0; }
.exact-side h5 { font-size: 12px; line-height: 18px; color: var(--text-2); }
.exact-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 14px; line-height: 22px; }
.empty-side { color: var(--text-2); font-style: italic; font-size: 14px; margin: 0; }
.exact-meta, .codepoints, .region-note { margin: 4px 0 0; font-size: 12px; line-height: 18px; color: var(--text-2); }

/* In-place editor (revised side of the selected row) */
.editor-label { display: block; font-size: 12px; line-height: 18px; font-weight: 700; color: var(--active); margin-bottom: 4px; }
#edit-text { display: block; width: 100%; padding: 8px 10px; font-size: 16px; line-height: 26px; border: 1px solid var(--active); border-radius: 6px; background: var(--surface); resize: vertical; tab-size: 4; scroll-margin: 120px 0 160px; }
#edit-text:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.editor .hint { margin: 4px 0 0; font-size: 12px; line-height: 18px; }
.edit-msg { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: var(--err-ink); }
.edit-msg:empty { display: none; }

/* Combined and clean views */
.context, .clean { padding: 16px 20px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.clean-text { white-space: pre-wrap; }
.clean-tools { display: flex; flex-wrap: wrap; gap: 8px; white-space: normal; margin: -4px 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.stepbar.is-clean { display: none; }
.clean-note { white-space: normal; font-size: 14px; color: var(--text-2); }
.ctx-region { border-radius: 4px; cursor: pointer; scroll-margin: 120px 0 90px; }
.ctx-region:focus { outline: none; }
.ctx-region.is-current { box-shadow: 0 0 0 2px var(--active); }
.ctx-num { font-size: 0.68em; font-weight: 700; color: var(--active); border: 1px solid var(--active); border-radius: 99px; padding: 0 0.38em; margin-right: 0.15em; vertical-align: 0.35em; }
.ctx-elided { display: block; margin: 4px 0; color: var(--text-2); font-size: 12px; font-style: italic; }
.context-note { margin: 0 0 8px; }

/* Step bar: previous / check / next */
.stepbar { position: sticky; bottom: 0; z-index: 12; display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--border); }
.btn-mark { min-width: 200px; }
.btn-step { padding: 0 12px; }
.arr { font-size: 18px; line-height: 1; }
.pos { margin-left: auto; font-size: 12px; line-height: 18px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.all-reviewed { margin: 0; padding: 10px 20px; border-top: 1px solid var(--divider); background: var(--ins-row); color: var(--ins-ink); font-size: 14px; line-height: 20px; font-weight: 600; }
.results-foot { margin: 0; padding: 8px 20px 12px; font-size: 12px; line-height: 18px; border-top: 1px solid var(--divider); }

/* Change list rail */
.rail { min-width: 0; background: var(--surface); }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--divider); }
.rail-head h3 { font-size: 14px; line-height: 20px; font-weight: 700; }
.change-list { list-style: none; margin: 0; padding: 0; }
.ch { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px; align-items: start; width: 100%; min-height: 44px; padding: 8px 12px 8px 12px; margin: 0; text-align: start; font: inherit; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--divider); cursor: pointer; }
.ch:hover { background: var(--surface-2); }
.ch[aria-current="true"] { background: var(--active-soft); box-shadow: inset 3px 0 0 var(--active); }
.ch-num { font-size: 12px; line-height: 20px; font-weight: 700; color: var(--text-2); }
.ch-text { min-width: 0; display: flex; flex-direction: column; }
.ch-phrase { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 20px; } /* relative: its screen-reader labels (position: absolute) are clipped here instead of widening the rail */
.ch-meta { font-size: 12px; line-height: 18px; color: var(--text-2); }
.ch-state { font-size: 12px; line-height: 20px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ch.is-done .ch-state { color: var(--ins-ink); }
#btn-more { margin: 8px; }
.rail-close { display: none; }

.results.is-stale .canvas, .results.is-stale .context, .results.is-stale .clean, .results.is-stale .change-list, .results.is-stale .watch-list { opacity: 0.55; }
.results-foot, .hint.results-foot { color: var(--text-2); }

/* Guide */
.prose { max-width: 760px; }
.prose h1 { font-size: 28px; line-height: 36px; margin-bottom: 8px; }
.prose .lead { color: var(--text-2); }
.prose section { margin-top: 28px; }
.prose h2 { font-size: 18px; line-height: 26px; margin-bottom: 6px; }
.preview { margin: 20px 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.preview figcaption { font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.pv-list { margin: 0 0 6px; padding-left: 20px; }
.pv-line { font-size: 12px; color: var(--text-2); }

/* Wide: rail beside the canvas */
@media (min-width: 1180px) {
  .work { grid-template-columns: minmax(0, 1fr) 240px; }
  .rail { border-left: 1px solid var(--border); position: sticky; top: 52px; align-self: start; max-height: calc(100vh - 52px); overflow-y: auto; border-radius: 0 0 10px 0; }
  .rail-head { position: sticky; top: 0; background: var(--surface); z-index: 1; }
  #btn-list { display: none; }
}
/* Narrower: the rail is a drawer */
@media (max-width: 1179px) {
  .rail { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(340px, 92vw); overflow-y: auto; border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgb(24 33 47 / 0.14); transform: translateX(100%); visibility: hidden; }
  .results.rail-open .rail { transform: none; visibility: visible; }
  .rail-close { display: inline-flex; min-width: 44px; min-height: 44px; font-size: 20px; }
}
@media (max-width: 1100px) { .shell, .top-in, .footer-in { padding-left: 24px; padding-right: 24px; } }
/* Phone */
@media (max-width: 767px) {
  :root { --ctl: 44px; }
  .top-in { min-height: 48px; padding: 0 16px; gap: 0 4px; }
  .brand { font-size: 15px; }
  .lang-nav { flex-basis: 100%; margin-left: -8px; }
  .lang-nav a, .site-nav a { padding: 0 6px; }
  .shell { padding: 16px 16px 32px; }
  .footer-in { padding: 16px; }
  .intro h1 { font-size: 24px; line-height: 32px; }
  .intro .lead { font-size: 15px; line-height: 24px; }
  .doc { border-radius: 8px; }
  .cols, .cols-head { grid-template-columns: minmax(0, 1fr); }
  .pane-b { border-left: 0; border-top: 1px solid var(--border); }
  .pane textarea { height: 200px; padding: 12px 16px; }
  .pane-head { padding: 0 8px 0 16px; }
  .bar { padding: 6px 8px; }
  .input-foot { position: sticky; bottom: 0; z-index: 12; background: var(--surface); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .doc:has(.pane textarea:focus) .input-foot { position: static; }
  .btn-compare { flex: 1 1 auto; }
  .bar-result { gap: 4px 6px; position: static; }
  .stepbar.is-editing { display: none; }
  .seg { order: 5; width: 100%; }
  .seg button { flex: 1 1 0; min-height: 44px; padding: 0 6px; }
  .cols-head { display: none; }
  /* Rows read top to bottom: original, then revised; unchanged lines once. */
  .row { grid-template-columns: minmax(0, 1fr); }
  .cell { padding: 8px 12px 8px 40px; }
  .cell-b { border-left: 0; }
  .gut { width: 36px; padding-right: 4px; gap: 3px; }
  .row:not(.is-changed) .cell-a { display: none; }
  .row.is-changed .cell-b { border-top: 1px dashed var(--border); }
  .row.is-changed .cell-label { position: static !important; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; display: block; font-size: 12px; line-height: 18px; font-weight: 700; color: var(--text-2); }
  .row.is-selected .txt { font-size: 17px; line-height: 28px; }
  .row-tools { padding: 10px 12px; }
  .sel-actions { margin-left: 0; width: 100%; }
  .sel-actions .btn { flex: 1 1 auto; }
  .exact-grid { grid-template-columns: minmax(0, 1fr); }
  .stepbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .btn-step .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .btn-step { min-width: 48px; }
  .btn-mark { min-width: 0; }
  .pos { grid-column: 1 / -1; margin: 0; text-align: center; }
  .take .popover { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; }
  .watch-list { grid-template-columns: minmax(0, 1fr); }
  .find { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
@media print { .top, .bar, .stepbar, .rail, .site-footer, .row-tools { display: none !important; } }
@media (max-width: 360px) { .seg button { font-size: 13px; padding: 0 4px; } .bar { gap: 2px 4px; } }

/* r9: quiet paper workspace, with a distinct ink/teal identity. */
:root { --page:#f3f6f5; --active:#126457; --active-strong:#084c40; --active-soft:#eaf6f1; --active-line:#b8ded3; --border:#d4dfdc; --divider:#e5ece9; --ctl:44px; }
.intro { display:flex; align-items:center; justify-content:space-between; gap:24px; margin:22px 0; }
.intro-text { min-width:0; }
.intro .eyebrow { font-size:12px; line-height:20px; letter-spacing:.1em; font-weight:700; color:var(--active); margin-bottom:6px; }
.intro h1 { font-size:32px; line-height:1.3; letter-spacing:-.035em; margin-bottom:8px; }
.intro .lead { font-size:15px; line-height:24px; margin:0; }
.workspace-art { width:130px; height:86px; flex:none; }
.doc { border-radius:14px; box-shadow:0 8px 32px rgb(27 65 55 / .045); }
.btn { border-radius:8px; transition:background-color 150ms,border-color 150ms,box-shadow 150ms; }
.btn-primary { box-shadow:0 2px 4px rgb(18 100 87 / .08); }
.pane textarea { background:linear-gradient(#fff,#fcfefd); }
.row.is-selected { transition:background-color 150ms; }
.workflow { border-bottom:1px solid var(--border); background:var(--surface); }
.wf-nav { display:flex; flex-wrap:wrap; gap:6px; padding:10px 16px; background:#f9fcfa; }
.wf-tab { font:inherit; font-size:13px; line-height:20px; min-height:44px; padding:0 14px; border:1px solid var(--border); border-radius:24px; color:var(--text-2); background:#fff; cursor:pointer; transition:background-color 150ms,border-color 150ms; }
.wf-tab::before { content:'+'; margin-right:7px; font-size:16px; }
.wf-tab[aria-expanded="true"] { border-color:var(--active); background:var(--active-soft); color:var(--active); font-weight:700; }
.wf-tab[aria-expanded="true"]::before { content:'−'; }
.wf-panel { padding:18px 20px; max-width:100%; animation:wf-reveal 150ms ease-out; }
@keyframes wf-reveal { from{opacity:.65} to{opacity:1} }
.wf-panel h3 { font-size:17px; margin-bottom:12px; }
.wf-presets,.wf-store-row,.wf-filters { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.wf-panel label { font-size:13px; color:var(--text-2); display:block; margin-bottom:4px; }
.wf-input,.wf-summary { width:100%; min-width:0; font:inherit; font-size:14px; line-height:22px; border:1px solid var(--border); border-radius:8px; background:#fff; color:var(--text); padding:10px 12px; }
.wf-panel input.wf-input { min-height:44px; }
#wf-profile-name { max-width:480px; margin-bottom:12px; }
.wf-check-list,.wf-form-list { padding:0; margin:0 0 16px; list-style:none; }
.wf-check-list { max-width:780px; }
.wf-check { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; align-items:center; gap:8px; margin-bottom:8px; }
.wf-check input[type="checkbox"] { width:22px; height:22px; margin:11px; accent-color:var(--active); }
.wf-check .wf-input { font-size:14px; }
.wf-remove { width:44px; height:44px; border:1px solid var(--border); border-radius:8px; background:white; font-size:20px; color:var(--text-2); cursor:pointer; }
.wf-add-row { display:flex; flex-wrap:wrap; gap:8px; max-width:780px; margin-bottom:16px; }
.wf-add-row .wf-input { flex:1 1 240px; width:auto; }
.wf-count,.wf-status { font-size:13px; line-height:20px; font-weight:600; color:var(--active); }
.wf-status:empty { display:none; }
.wf-form { display:grid; grid-template-columns:135px minmax(0,1fr); gap:4px 12px; width:100%; text-align:start; font:inherit; border:1px solid var(--divider); border-radius:8px; background:#fff; padding:12px; margin-bottom:7px; color:var(--text); cursor:pointer; transition:background-color 150ms; }
.wf-form:hover { background:var(--active-soft); }
.wf-form:disabled { cursor:default; opacity:.55; }
.wf-form-kind { color:var(--active); font-size:12px; font-weight:700; }
.wf-form-pair { overflow-wrap:anywhere; word-break:normal; font-variant-numeric:tabular-nums; }
.wf-form-lines { grid-column:2; font-size:12px; line-height:18px; color:var(--text-2); }
.wf-filter { border:1px solid var(--border); min-height:44px; padding:0 12px; border-radius:6px; background:#fff; font:inherit; font-size:13px; color:var(--text-2); cursor:pointer; }
.wf-filter[aria-pressed="true"] { color:var(--active); border-color:var(--active); background:var(--active-soft); }
#wf-panel-handoff { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
#wf-panel-handoff .wf-field:nth-child(3),#wf-panel-handoff>p,#wf-panel-handoff>.wf-store-row,#wf-panel-handoff>.wf-summary { grid-column:1/-1; }
.wf-summary { white-space:pre-wrap; min-height:180px; resize:vertical; }
@media(max-width:767px){ .intro {margin:16px 0;gap:12px;} .intro h1{font-size:25px;} .workspace-art{width:76px;height:60px;} .intro .eyebrow{font-size:11px;letter-spacing:0;} .wf-nav{padding:8px;gap:5px;} .wf-tab{padding:0 10px;font-size:12px;} .wf-panel{padding:14px 12px;} .wf-form{grid-template-columns:1fr;} .wf-form-lines{grid-column:1;} #wf-panel-handoff{grid-template-columns:1fr;} .wf-check{gap:4px;} }
@media(max-width:360px){.workspace-art{display:none;} .wf-tab{padding:0 8px;} .wf-tab::before{margin-right:4px;} }
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}
.motion-reduced *,.motion-reduced *::before,.motion-reduced *::after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}
#wf-motion{margin-top:10px;font-size:12px;}
#wf-motion[aria-pressed="true"]{color:var(--active);background:var(--active-soft);}
@media print{.workflow,.workspace-art{display:none!important;}}
.rail.wf-open .change-list,.rail.wf-open #btn-more{display:none!important;}
.rail .wf-panel{padding:12px;}
.rail .wf-form{grid-template-columns:1fr;gap:4px;}
.rail .wf-form-lines{grid-column:1;}
.rail .wf-form-pair{font-size:14px;line-height:22px;}
.rail #wf-panel-handoff{grid-template-columns:1fr;}
.rail .wf-store-row .btn{width:100%;}
.rail .wf-check{grid-template-columns:44px minmax(0,1fr) 44px;gap:4px;align-items:start;}
.rail .wf-check input[type="checkbox"]{margin:11px;}
.rail .wf-remove{width:44px;height:44px;border:0;}
.rail .wf-check .wf-input{padding:8px;font-size:13px;line-height:20px;resize:vertical;}
@media(min-width:1180px){.work{grid-template-columns:minmax(0,1fr) 300px;}}
.wf-check .wf-tick{display:flex;align-items:center;justify-content:center;width:44px;height:44px;margin:0;cursor:pointer;}
.wf-check .wf-tick input{margin:0;}
