/* ============================================================
   DIFF — unified diff system
   ============================================================ */

/* -- Empty section placeholder -- */
.empty-placeholder {
    font-style: italic;
    color: var(--t3);
    opacity: 0.7;
}

/* -- Diff box (monospace code-style diff in tool results / chat) -- */
.diff-box {
    font: 12px/1.65 var(--mono);
    background: var(--doc-border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--td1);
}
/* Chat-panel diff-box: stripped of bg + padding + max-height. The diff text
   flows inside the detail panel as inline content — green/red highlights
   carry the story; no extra box chrome is needed in the narrow column.
   The document area still gets the framed treatment via the base rule. */
#chat-panel .diff-box {
    font: 12px/1.55 var(--sans);
    background: none;
    padding: 0;
    margin: 0;
    max-height: none;
    color: var(--t2);
    word-break: break-word;
}
#chat-panel .diff-box .diff-add { background: var(--green-bg); color: var(--diff-add-color); }
#chat-panel .diff-box .diff-del {
    background: var(--red-bg);
    color: var(--diff-del-color);
    text-decoration: line-through;
    text-decoration-color: rgba(216,128,112,0.4);
}
#chat-panel .source-add-url {
    color: var(--t3);
    font-size: 11px;
    word-break: break-all;
}
/* Separator between distinct change blobs in renderChangesOnly view —
   small ellipsis that signals "unchanged text omitted here". */
.diff-skip {
    color: var(--t3);
    opacity: 0.5;
    padding: 0 4px;
    user-select: none;
}
/* Field label in metadata diff boxes — used inside .diff-field-row.
   Compact layout for narrow chat columns; the label is a small caps prefix,
   not a fixed-width column, so it doesn't waste horizontal space. */
.diff-field-row {
    padding: 1px 0;
    line-height: 1.5;
}
.diff-field-row + .diff-field-row { margin-top: 3px; }
.diff-field-label {
    font: 600 10px var(--sans);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--t3);
    margin-right: 4px;
}
.diff-field-label::after { content: ':'; }
.diff-field-arrow {
    color: var(--t3);
    opacity: 0.6;
    margin: 0 3px;
}
/* Truncate long diffs in chat change cards — the inline document diff is
   canonical, so the chat preview just hints at scope. Specificity matches
   the #chat-panel .diff-box rule above so max-height actually applies. */
#chat-panel .change-step .diff-box,
#chat-panel .chat-change .diff-box {
    max-height: 110px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
#chat-panel .change-step .diff-box::after,
#chat-panel .chat-change .diff-box::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 24px;
    background: linear-gradient(to bottom, transparent, rgba(15,28,46,0.85));
    pointer-events: none;
}

/* -- Base diff tokens (tool results, chat diff boxes) -- */
.diff-add { background: var(--green-bg); color: var(--diff-add-color); border-radius: var(--radius-2xs); padding: 0 1px; }
.diff-del { background: var(--red-bg); color: var(--diff-del-color); border-radius: var(--radius-2xs); padding: 0 1px; }

/* -- Document-context diff body (pending changes + checkpoint preview) -- */
/* .diff-body is the unified class; .inline-diff-body and .preview-diff-body kept for compat */
.diff-body,
.inline-diff-body,
.preview-diff-body {
    font: 16px/1.82 var(--serif);
    color: var(--td2b);
    padding: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}
/* Inline diff span fill — line-locked technique. Background uses a
   linear-gradient image sized to exactly `1lh` tall, centered vertically on
   each line via box-decoration-break: clone. Because bg height = line-height
   exactly (instead of being driven by font metrics + padding guesswork),
   adjacent wrapped lines' bgs touch precisely with zero overlap, regardless
   of the font's actual ascent/descent. Padding-block is generous so the
   1lh-tall bg has room to render fully; the bg-size constraint clips the
   gradient to exactly one line-height — extra padding area stays transparent.
   See pepelsbey.dev/articles/skewed-highlight for the technique reference. */
.diff-body .diff-add,
.inline-diff-body .diff-add,
.preview-diff-body .diff-add,
.preview-sources-diff .diff-add,
.diff-body .diff-del,
.inline-diff-body .diff-del,
.preview-diff-body .diff-del,
.preview-sources-diff .diff-del {
    background-color: transparent;
    background-size: 100% 1lh;
    background-position: 0 50%;
    background-repeat: no-repeat;
    border-radius: var(--radius-2xs);
    padding: 0.5em 2px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
/* Text color stays neutral (--td2) inside inline diff highlights. The wash
   carries the direction signal — green wash = added, red wash = removed.
   The text itself is just content; no need to color it too. Matches the
   "wash carries color, text is calm" principle used elsewhere. */
.diff-body .diff-add,
.inline-diff-body .diff-add,
.preview-diff-body .diff-add,
.preview-sources-diff .diff-add {
    background-image: linear-gradient(var(--green-bg), var(--green-bg));
    color: var(--td2);
    text-decoration: none;
}
.diff-body .diff-del,
.inline-diff-body .diff-del,
.preview-diff-body .diff-del,
.preview-sources-diff .diff-del {
    background-image: linear-gradient(var(--red-bg), var(--red-bg));
    color: var(--td2);
}

/* -- Figure blocks inside inline diffs (pending changes) -- */
.inline-diff-body .figure-block.diff-fig-add,
.deleted-ghost-body .figure-block.diff-fig-add { background: var(--green-bg); border-radius: var(--radius); padding: 8px; }
.inline-diff-body .figure-block.diff-fig-del,
.deleted-ghost-body .figure-block.diff-fig-del { background: var(--red-bg); border-radius: var(--radius); padding: 8px; }
.inline-diff-body .figure-block,
.deleted-ghost-body .figure-block { margin: 8px 0; }

/* -- Marker label chips (chat cards — compact figure/table/equation labels) -- */
.diff-marker-label {
    display: inline-block;
    font: 500 10px var(--sans);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    background: var(--chrome-border-subtle);
    color: var(--t3);
    vertical-align: baseline;
    letter-spacing: 0.02em;
}
.diff-add .diff-marker-label { background: var(--green-bg); color: var(--diff-add-color); }
.diff-del .diff-marker-label { background: var(--red-bg); color: var(--diff-del-color); }

/* -- Citation markers inside diffs: keep brick-red --doc-ochre in the
   document body (the green/red wash is signal enough; the marker stays
   visually anchored to the citation family). In the chat-panel diff,
   text itself is colored green/red, so match that to read coherently. */
#chat-panel .diff-add .cite-marker { color: var(--diff-add-color); }
#chat-panel .diff-del .cite-marker { color: var(--diff-del-color); }

/* -- Title diffs: normal text color, background is enough -- */
.section-title-input .diff-add,
.section-title-input .diff-del {
    color: inherit;
}

/* -- Deleted ghost body (deleted section preview) -- */
.deleted-ghost-body {
    font: 16px/1.82 var(--serif);
    color: var(--td2b);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow: hidden;
    position: relative;
}
/* Bottom fade-overlay removed — the gradient added a second red layer on
   top of the section-inner red wash, creating a visibly darker band. With
   max-height: 200px the content has a natural truncation; the section's
   border-radius softens the bottom edge enough on its own. */
