/*
 * The diff page (diff.html). Loaded after styles.css and auth.css, whose app
 * shell, header, buttons and dialog styles it builds on — not pages.css, whose
 * body line-height and scrolling body fight the full-height app shell.
 *
 * Severity colours reuse the editor's token palette so a diff reads as the same
 * product: green = --json-string (added), red = --json-null (removed), amber =
 * --json-number (changed), purple = --json-boolean (type). Search hits are a
 * blue RING, never the editor's amber fill, which would vanish on an amber row.
 *
 * The panes use white-space: pre and a fixed 22px row, so left and right rows
 * line up by CSS alone — no measuring, no ResizeObserver.
 */

:root {
  --diff-add: #047857;
  --diff-add-bg: #e6f4ea;
  --diff-add-gutter: #cfe9d8;
  --diff-add-strong: #bbe5c9;
  --diff-del: #dc2626;
  --diff-del-ink: #b42318;
  --diff-del-bg: #fdecea;
  --diff-del-gutter: #fbdcd8;
  --diff-del-strong: #f6c9c3;
  --diff-chg: #b45309;
  --diff-chg-ink: #92400e;
  --diff-chg-bg: #fff7e6;
  --diff-chg-gutter: #fdeccd;
  --diff-chg-strong: #fbd9a5;
  --diff-type: #7e22ce;
  --diff-type-bg: #f5ecfd;
  --diff-type-gutter: #efe2fb;
  --diff-type-strong: #e3ccf9;
  --diff-ign: #9ca3af;
  --diff-ign-bg: #f4f6f9;
  --diff-ign-ink: #8b94a3;
  --diff-gap-a: #e4eaf1;
  --diff-gap-b: #f3f6fa;
  --diff-hit: #2563eb;
  --diff-row: 22px;
  --diff-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pro: #5b21b6;
  --pro-bg: #ede9fe;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── page frame ─────────────────────────────────────────────────────── */

.diff-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.diff-toolbar {
  position: static;
}

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
  margin: 0 0.15rem;
}

.diff-toolbar button,
.diff-input-foot button,
.diff-summary button,
.diff-drawer button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button.small {
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
}

button.linkish {
  background: transparent;
  border: none;
  color: var(--primary);
  padding: 0.25rem 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.button-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.button-link.pro {
  background: #6d28d9;
}

.segmented {
  display: inline-flex;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.3rem 0.7rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 6px;
}

.segmented button[aria-pressed="true"] {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.12);
}

.segmented.small button {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
}

.count-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  min-width: 16px;
  height: 16px;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.pro-pill {
  background: var(--pro-bg);
  color: var(--pro);
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 5px;
  letter-spacing: 0.4px;
}

body.is-pro [data-pro-pill] {
  display: none;
}

.diff-find {
  flex: 1;
  min-width: 220px;
}

#diff-find-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-family: var(--diff-mono);
  font-size: 0.85rem;
}

.diff-out {
  margin-left: auto;
}

.strip-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
}

/* ── find options ───────────────────────────────────────────────────── */

.diff-find-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0.45rem 0.9rem;
  background: #fbfdff;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.diff-find-options[hidden] {
  display: none;
}

.diff-find-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.diff-find-folded {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #1e3a8a;
  background: #eef4ff;
  border: 1px solid #cdd8e6;
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
}

/* ── summary: counts that are also filters ─────────────────────────── */

.diff-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.55rem 0.9rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.diff-summary[hidden] {
  display: none;
}

.diff-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.diff-chip-list {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 30px;
  padding: 0 0.3rem 0 0.5rem;
  border: 1px solid #d9dee6;
  border-radius: 8px;
  background: #fff;
  font-size: 0.82rem;
}

.chip label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  padding-right: 0.25rem;
}

.chip input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--primary);
}

.chip .swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chip.off {
  border-style: dashed;
  border-color: #cfd6e0;
  background: #f8fafc;
  color: var(--diff-ign);
}

.chip.off .swatch {
  opacity: 0.4;
}

/* "only" floats above the chip rather than taking space in it: showing and
   hiding it must never move the row, or a click aimed at "Show all" lands on
   whatever slid under the pointer between mouse-down and mouse-up. */
.chip {
  position: relative;
}

.chip .chip-only {
  position: absolute;
  bottom: calc(100% - 6px);
  right: 4px;
  z-index: 20;
  visibility: hidden;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(15, 12, 8, 0.18);
}

.chip:hover,
.chip:focus-within {
  border-color: #93c5fd;
}

.chip:hover .chip-only,
.chip:focus-within .chip-only {
  visibility: visible;
}

.swatch.added { background: var(--diff-add); }
.swatch.removed { background: var(--diff-del); }
.swatch.changed { background: var(--diff-chg); }
.swatch.type { background: var(--diff-type); }
.swatch.ignored { background: #cbd5e1; }

.diff-unchanged {
  color: var(--diff-ign);
  font-size: 0.85rem;
}

.diff-fold-toggle,
.diff-context {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text);
}

.diff-context input {
  width: 2.9rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.diff-summary-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.breaking-pill {
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: var(--diff-del-ink);
  font-weight: 600;
  font-size: 0.82rem;
}

/* ── notices ────────────────────────────────────────────────────────── */

.diff-notices:empty {
  display: none;
}

.diff-notices {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg);
}

.diff-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.45;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
}

.diff-notice.info {
  background: #eef4ff;
  border-color: #cdd8e6;
  color: #1e3a8a;
}

.diff-notice.error {
  background: #fef3f2;
  border-color: #fecdca;
  color: #7a271a;
}

.diff-notice button {
  margin-left: auto;
  flex-shrink: 0;
}

/* ── inputs ─────────────────────────────────────────────────────────── */

.diff-inputs {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1rem 0;
}

.diff-inputs[hidden] {
  display: none;
}

.diff-input {
  flex: 1;
  flex-basis: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.diff-input.dragging {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.diff-input-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0 0.85rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fbfdff;
  font-size: 0.82rem;
}

.side-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
}

.side-hint {
  color: var(--muted);
}

.side-name {
  margin-left: auto;
  font-family: var(--diff-mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45%;
}

.diff-textarea {
  flex: 1;
  min-height: 0;
  resize: none;
  border: none;
  outline: none;
  padding: 0.75rem 0.85rem;
  font-family: var(--diff-mono);
  font-size: 0.85rem;
  line-height: 22px;
  color: var(--text);
  background: #fbfdff;
  white-space: pre;
  overflow: auto;
}

.diff-input-error {
  margin: 0;
  padding: 0.5rem 0.85rem;
  background: #fef3f2;
  border-top: 1px solid #fecdca;
  color: var(--diff-del-ink);
  font-size: 0.82rem;
}

.diff-input-error[hidden],
.diff-url-row[hidden] {
  display: none;
}

.diff-url-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid #e5e7eb;
}

.diff-url-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
}

.diff-input-foot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0 0.7rem;
  border-top: 1px solid #e5e7eb;
  background: #fbfdff;
}

.side-size {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--diff-ign);
}

.side-size.over {
  color: var(--diff-del-ink);
  font-weight: 600;
}

.diff-swap-mid {
  display: flex;
  align-items: center;
}

.diff-swap-mid button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.diff-input-footer {
  padding: 0.85rem 1rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.diff-input-footer p {
  margin: 0.15rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.diff-input-footer[hidden] {
  display: none;
}

/* ── result ─────────────────────────────────────────────────────────── */

.diff-result {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.diff-result[hidden],
.diff-split[hidden],
.diff-unified[hidden] {
  display: none;
}

.diff-split {
  flex: 1;
  min-height: 0;
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.diff-side {
  flex: 1;
  flex-basis: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.diff-side + .diff-side {
  border-left: 1px solid var(--border);
}

.diff-side-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 34px;
  padding: 0 0.75rem;
  background: #fbfdff;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.side-label {
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.side-file {
  font-family: var(--diff-mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-meta {
  color: var(--diff-ign);
  white-space: nowrap;
}

.diff-side-head .linkish {
  margin-left: auto;
  white-space: nowrap;
}

.diff-unified {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.diff-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fbfdff;
  outline: none;
  font-family: var(--diff-mono);
  font-size: 12.5px;
  line-height: var(--diff-row);
}

.diff-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

/* One row: sticky gutter, sticky marker, code. Line numbers and markers are
   pseudo-element content, so find-in-page and copying see only the code. */
.drow {
  display: flex;
  height: var(--diff-row);
  width: max-content;
  min-width: 100%;
  white-space: pre;
}

.dln,
.dln2 {
  position: sticky;
  left: 0;
  width: 48px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 8px;
  color: var(--diff-ign);
  font-size: 11px;
  background: #f8fafc;
  border-right: 1px solid #e8edf3;
  user-select: none;
  z-index: 1;
}

.dln::before,
.dln2::before {
  content: attr(data-n);
}

.dmk {
  position: sticky;
  left: 48px;
  width: 18px;
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  user-select: none;
  background: inherit;
  z-index: 1;
}

.dmk::before {
  content: attr(data-m);
}

.dcode {
  padding: 0 1rem 0 0.6rem;
}

/* Unified rows have two line-number columns. */
.urow .dln {
  border-right: none;
}

.urow .dln2 {
  left: 48px;
}

.urow .dmk {
  left: 96px;
}

/* Tints apply only to rows whose category is shown (class "t"). */
.drow.t.s-added { background: var(--diff-add-bg); }
.drow.t.s-added .dln,
.drow.t.s-added .dln2 { background: var(--diff-add-gutter); color: #046c4a; }
.drow.t.s-added .dmk { color: var(--diff-add); }

.drow.t.s-removed { background: var(--diff-del-bg); }
.drow.t.s-removed .dln,
.drow.t.s-removed .dln2 { background: var(--diff-del-gutter); color: var(--diff-del-ink); }
.drow.t.s-removed .dmk { color: var(--diff-del); }

.drow.t.s-changed,
.drow.t.s-deep { background: var(--diff-chg-bg); }
.drow.t.s-changed .dln,
.drow.t.s-changed .dln2,
.drow.t.s-deep .dln { background: var(--diff-chg-gutter); color: var(--diff-chg-ink); }
.drow.t.s-changed .dmk,
.drow.t.s-deep .dmk { color: var(--diff-chg); }

.drow.t.s-type { background: var(--diff-type-bg); }
.drow.t.s-type .dln,
.drow.t.s-type .dln2 { background: var(--diff-type-gutter); color: var(--diff-type); }
.drow.t.s-type .dmk { color: var(--diff-type); }

.drow.t.s-ignored { background: var(--diff-ign-bg); }
.drow.t.s-ignored .dln,
.drow.t.s-ignored .dln2 { background: #eaeef4; }
.drow.t.s-ignored .dmk { color: var(--diff-ign); }
.drow.t.s-ignored .dcode,
.drow.t.s-ignored .dcode span { color: #a3abb8; }

.drow.gap {
  background-image: repeating-linear-gradient(
    135deg,
    var(--diff-gap-a) 0,
    var(--diff-gap-a) 3px,
    var(--diff-gap-b) 3px,
    var(--diff-gap-b) 7px
  );
}

.drow.gap .dln,
.drow.gap .dln2 {
  background: #e9eef4;
}

/* The part of a changed row that changed. */
.drow.t.s-changed .dval { background: var(--diff-chg-strong); border-radius: 3px; }
.drow.t.s-removed .dval { background: var(--diff-del-strong); border-radius: 3px; }
.drow.t.s-added .dval { background: var(--diff-add-strong); border-radius: 3px; }
.drow.t.s-type .dval { background: var(--diff-type-strong); border-radius: 3px; }

.drow.flash {
  animation: diff-flash 1.2s ease;
}

@keyframes diff-flash {
  0%, 35% { box-shadow: inset 0 0 0 2px var(--diff-hit); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}

.utype {
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--diff-type);
  margin-left: 0.75rem;
}

/* Search hits: a ring survives every row colour; the current hit is solid. */
mark.dhit {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 0 0 2px var(--diff-hit);
  border-radius: 3px;
}

mark.dhit.on {
  background: var(--diff-hit);
  color: #fff;
}

mark.dhit.on span,
mark.dhit.on {
  color: #fff;
}

/* A fold: unchanged lines — and filtered-out changes, which it names. */
.dfold {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 28px;
  width: max-content;
  min-width: 100%;
  padding: 0 0.75rem 0 1rem;
  background: #eef2f8;
  border-top: 1px solid #dde4ee;
  border-bottom: 1px solid #dde4ee;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12px;
  color: #5b6472;
  white-space: nowrap;
}

.dfold .dfold-hidden {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dfold .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.dfold button {
  background: #fff;
  color: var(--primary);
  border: 1px solid #cdd8e6;
  border-radius: 6px;
  padding: 1px 9px;
  font-size: 11.5px;
  font-weight: 600;
}

.diff-empty {
  padding: 2rem;
  text-align: center;
  font-family: Inter, system-ui, sans-serif;
  color: var(--muted);
}

/* Token colours inside the panes (same classes as the editor). */
.diff-scroll .json-key { color: var(--json-key); }
.diff-scroll .json-string { color: var(--json-string); }
.diff-scroll .json-number { color: var(--json-number); }
.diff-scroll .json-boolean { color: var(--json-boolean); }
.diff-scroll .json-null { color: var(--json-null); }
.diff-scroll .json-punctuation { color: var(--json-punctuation); }

/* ── change list ────────────────────────────────────────────────────── */

.diff-changes {
  flex-shrink: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  max-height: 34vh;
}

.diff-changes-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.82rem;
}

.diff-changes-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#diff-path-filter {
  width: 15rem;
  font-family: var(--diff-mono);
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#diff-path-filter.invalid {
  border-color: #fca5a5;
}

#diff-changes-toggle {
  margin-left: auto;
}

.diff-changes-list {
  list-style: none;
  margin: 0;
  padding: 0 0.9rem;
  overflow: auto;
  min-height: 0;
}

.diff-changes-list[hidden] {
  display: none;
}

.clrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 34px;
  border-bottom: 1px solid #f1f3f7;
  font-size: 0.82rem;
}

.clrow > button.cljump {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: none;
  color: inherit;
  padding: 0.3rem 0;
  text-align: left;
}

.clrow > button.cljump:hover .clpath,
.clrow > button.cljump:focus-visible .clpath {
  text-decoration: underline;
}

.clkind {
  width: 6.2rem;
  flex-shrink: 0;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.clkind.added { color: var(--diff-add); }
.clkind.removed { color: var(--diff-del); }
.clkind.changed,
.clkind.deep { color: var(--diff-chg); }
.clkind.type { color: var(--diff-type); }
.clkind.ignored { color: var(--diff-ign); }

.clpath {
  font-family: var(--diff-mono);
  color: var(--text);
  min-width: 10rem;
  max-width: 34%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clvals {
  font-family: var(--diff-mono);
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clvals .arrow {
  color: var(--diff-ign);
  margin: 0 0.4rem;
}

.clvals .absent,
.clvals .tname {
  color: var(--diff-ign);
}

.clhint {
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--diff-chg-ink);
  background: var(--diff-chg-bg);
  border-radius: 4px;
  padding: 0 0.35rem;
}

.clrow .clact {
  flex-shrink: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.clrow .clact.rule {
  color: var(--primary);
  border-color: #bfdbfe;
}

.clmore {
  padding: 0.6rem 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── rules drawer ───────────────────────────────────────────────────── */

.diff-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 44px rgba(20, 20, 19, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 90;
}

.diff-drawer[hidden] {
  display: none;
}

.diff-drawer-head {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 1.2rem;
  border-bottom: 1px solid #e5e7eb;
}

.diff-drawer-head h2 {
  margin: 0;
  font-size: 1rem;
}

.icon-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.3rem;
}

.diff-drawer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.6rem 1.2rem 1.2rem;
}

.diff-drawer .sec {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--muted);
  text-transform: uppercase;
  margin: 1.1rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rule-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.3rem 0;
}

.rule-check .muted {
  font-size: 0.8rem;
}

.rule-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  padding: 0.45rem 0;
}

.rule-inline input {
  width: 7rem;
  font-family: var(--diff-mono);
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.rule-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.rule-row input {
  min-width: 0;
  font-family: var(--diff-mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.rule-row input.path {
  flex: 1;
}

.rule-row input.key {
  width: 7rem;
}

.rule-row input.invalid {
  border-color: #fca5a5;
  background: #fff5f5;
}

.rule-row .hits {
  font-size: 0.75rem;
  color: var(--diff-ign);
  width: 5.5rem;
  text-align: right;
  flex-shrink: 0;
}

.rule-row .hits.none {
  color: var(--diff-del);
  font-weight: 600;
}

.rule-row .rule-error {
  font-size: 0.72rem;
  color: var(--diff-del-ink);
}

.rule-row button.remove {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: var(--diff-ign);
  border-radius: 7px;
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  flex-shrink: 0;
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.preset-row .preset-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.syntax code {
  background: #f1f3f7;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
}

.diff-drawer-foot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 62px;
  padding: 0 1.2rem;
  border-top: 1px solid #e5e7eb;
  background: #fbfdff;
}

.diff-drawer-foot .secondary {
  margin-left: auto;
}

/* ── dialogs ────────────────────────────────────────────────────────── */

.diff-dialog-overlay .share-modal {
  max-width: 560px;
}

.diff-report.share-modal {
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.diff-report .share-modal-body {
  overflow: auto;
  min-height: 0;
}

.sample-pill {
  background: #eef2f8;
  color: #475467;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  vertical-align: middle;
  margin-left: 0.5rem;
}

.report-direction {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  margin: 0 0 0.6rem;
}

.report-caveat {
  margin: 0 0 0.9rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #475467;
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
  border-radius: 0 7px 7px 0;
  padding: 0.6rem 0.75rem;
}

.report-section {
  margin: 0.9rem 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.report-section.breaking { color: var(--diff-del-ink); }
.report-section.warning { color: var(--diff-chg-ink); }
.report-section.additive { color: #046c4a; }

.finding {
  border-radius: 9px;
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.finding.breaking { background: #fef3f2; border: 1px solid #fecdca; }
.finding.warning { background: #fffbeb; border: 1px solid #fde68a; }
.finding.additive { background: #f0f9f3; border: 1px solid #c3e6d0; }

.finding .fpath {
  font-family: var(--diff-mono);
  font-weight: 600;
}

.finding .ftypes {
  margin-left: 0.5rem;
  font-weight: 600;
}

.finding p {
  margin: 0.2rem 0 0;
}

.finding .fcaveat {
  color: var(--muted);
  font-style: italic;
  font-size: 0.8rem;
}

.report-none {
  color: var(--muted);
  padding: 0.5rem 0;
}

.diff-dialog-foot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.2rem;
  border-top: 1px solid #e5e7eb;
  background: #fbfdff;
  border-radius: 0 0 16px 16px;
}

.diff-dialog-foot > :first-child:not(button):not(a) {
  margin-right: auto;
}

.diff-dialog-foot > button:last-child,
.diff-dialog-foot > a:last-child {
  margin-left: auto;
}

.limit-alert {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  color: var(--diff-del-ink);
}

.limit-alert p {
  margin: 0.3rem 0 0;
  color: #7a271a;
  font-size: 0.85rem;
  line-height: 1.5;
}

.limit-original {
  margin-top: 0.9rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  color: #1e3a8a;
  font-size: 0.85rem;
}

.limit-original[hidden] {
  display: none;
}

.limit-original p {
  margin: 0 0 0.6rem;
}

/* Size bars, in the share dialog and the refusal. */
.size-bars:empty {
  display: none;
}

.size-bars {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.82rem;
}

.size-bars .size-title,
.share-opens .size-title {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.size-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.size-bar .side {
  width: 2.8rem;
}

.size-bar .track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
  display: flex;
}

.size-bar .fill {
  background: var(--primary);
  border-radius: 999px;
}

.size-bar.over .fill {
  background: var(--diff-del);
}

.size-bar .amount {
  flex: none;
  min-width: 11rem;
  white-space: nowrap;
  text-align: right;
  font-family: var(--diff-mono);
  font-size: 0.78rem;
}

.size-bar.over .amount {
  color: var(--diff-del-ink);
  font-weight: 600;
}

.share-opens:empty {
  display: none;
}

.share-opens {
  margin-top: 0.9rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}

.share-opens .opens-row {
  display: flex;
  gap: 0.75rem;
}

.share-opens .opens-key {
  width: 3rem;
  flex-shrink: 0;
  color: var(--muted);
}

.share-opens .opens-val {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-opens code {
  font-family: var(--diff-mono);
}

.share-life {
  margin: 0.8rem 0 0;
}

/* ── export menu ────────────────────────────────────────────────────── */

.diff-menu {
  position: fixed;
  z-index: 95;
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 12, 8, 0.16);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
}

.diff-menu[hidden] {
  display: none;
}

.diff-menu button {
  background: transparent;
  color: var(--text);
  border: none;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
}

.diff-menu button:hover,
.diff-menu button:focus-visible {
  background: #eef4ff;
}

/* ── opened from a share link ───────────────────────────────────────── */

.diff-shared-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 0.8rem;
  padding: 0.55rem 1rem;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  font-size: 0.85rem;
  color: #1e3a8a;
}

.diff-shared-banner[hidden] {
  display: none;
}

.diff-shared-banner code {
  font-family: var(--diff-mono);
  color: var(--text);
}

.diff-shared-banner .dot {
  color: #93a4c3;
}

.diff-shared-banner .note {
  margin-left: auto;
  color: #475467;
  font-size: 0.82rem;
}

/* ── small screens: unified only, inputs stacked ───────────────────── */

@media (max-width: 768px) {
  .diff-inputs {
    flex-direction: column;
    padding: 0.6rem 0.6rem 0;
  }

  .diff-input {
    min-height: 220px;
  }

  .diff-swap-mid {
    justify-content: center;
  }

  .diff-swap-mid button {
    transform: rotate(90deg);
  }

  #diff-view-split {
    display: none;
  }

  .diff-summary-end {
    margin-left: 0;
    width: 100%;
  }

  .diff-find {
    min-width: 0;
    width: 100%;
  }

  .diff-out {
    margin-left: 0;
  }

  .clpath {
    min-width: 7rem;
    max-width: 45%;
  }

  .clvals {
    display: none;
  }

  .diff-toolbar .btn-label {
    display: none;
  }

  .app-header-sep,
  .app-tagline {
    display: none;
  }
}
