.view:has(.diff-page) { display: block; overflow-y: auto; padding: 20px; }
.diff-page { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; height: 100%; }
.diff-head { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border: 1px solid var(--border); background: var(--surface); }
.diff-head > div:first-child { display: grid; gap: 2px; }
.diff-head small { color: var(--faint); font-size: 10px; }
.diff-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.diff-layout { display: grid; grid-template-columns: clamp(160px, 24%, 280px) minmax(0, 1fr); min-height: 0; border: 1px solid var(--border); background: var(--surface); }
.diff-files { display: grid; align-content: start; overflow: auto; border-right: 1px solid var(--border); }
.diff-file { display: grid; gap: 3px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--fg); text-align: left; font: inherit; cursor: pointer; }
.diff-file:hover, .diff-file.on { background: var(--surface2); }
.diff-file.on { box-shadow: inset 2px 0 var(--accent); }
.diff-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-file small { color: var(--faint); font-size: 10px; }
.diff-content { min-width: 0; overflow: auto; }
.diff-block > summary { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--muted); cursor: pointer; font-size: 11px; }
.diff-patch, .tool-diff pre { margin: 0; padding: 12px 14px; overflow: auto; background: var(--bg); color: var(--muted); font: 12.5px/1.65 var(--mono); white-space: pre; user-select: text; }
.diff-patch span, .tool-diff span { display: block; min-height: 1.65em; }
.diff-patch .add, .tool-diff .add { background: color-mix(in srgb, var(--teal) 18%, transparent); color: color-mix(in srgb, var(--teal) 65%, white); }
.diff-patch .del, .tool-diff .del { background: color-mix(in srgb, var(--red) 18%, transparent); color: color-mix(in srgb, var(--red) 68%, white); }
.diff-patch .hunk { color: var(--accent); }
.diff-empty { display: grid; align-content: center; justify-items: center; gap: 12px; margin: 0; padding: 24px; border: 1px dashed var(--border); color: var(--muted); text-align: center; }
.diff-empty p { margin: 0; max-width: 520px; line-height: 1.6; }
.diff-confirm { position: fixed; inset: 0; z-index: 8; display: grid; align-content: center; justify-items: center; gap: 12px; padding: 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); }
.diff-confirm > b, .diff-confirm > p, .diff-confirm > .diff-actions { width: min(560px, 100%); padding: 14px; border: 1px solid var(--border); background: var(--surface); }
.diff-confirm > p { margin: -12px 0 0; color: var(--muted); font: 11px/1.6 var(--mono); white-space: pre-wrap; }
.diff-confirm > .diff-actions { justify-content: flex-end; margin-top: -12px; }
.turn-link { display: block; margin: 4px 0 0 auto; padding: 2px 0; border: 0; background: none; color: var(--accent); font: 10px var(--mono); cursor: pointer; }
.turn-link:hover { color: var(--fg); text-decoration: underline; }
.turn-link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.tool-diff { overflow: hidden; border: 1px solid var(--border); }
@media (max-width: 700px) {
  .diff-page { min-height: calc(100vh - 96px); }
  .diff-head { align-items: flex-start; flex-wrap: wrap; }
  .diff-actions { width: 100%; margin-left: 0; }
  .diff-actions .m-btn { flex: 1; }
  .diff-layout { grid-template-columns: minmax(125px, 38%) minmax(0, 1fr); min-height: min(520px, calc(100vh - 180px)); }
  .diff-file { padding: 8px; }
  .diff-patch { padding: 8px; font-size: 10px; }
}
/* Edits view (views/edits.js): the turn-diff layout, files grouped under each AI, the selected file's hunks newest first. */
.edits-modes button { min-width: 76px; padding: 0 12px; }
.edits-ai { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface2); color: var(--muted); font-size: 11px; font-weight: 600; }
.edits-ai-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edits-ai small { color: var(--faint); font: 10px var(--mono); }
.edits-ai.pinned .edits-ai-name, .edits-file.pinned b { color: var(--accent); }
.edits-file b { font-weight: 600; }
.edits-file i { color: var(--faint); font-style: normal; font-size: 11px; }
.edits-state { font-style: normal; }
.edits-state.running { color: var(--accent); }
.edits-state.failed { color: var(--red); }
.edits-file-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: baseline; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.edits-file-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12px var(--mono); }
.edits-file-head small { margin-left: auto; color: var(--faint); font-size: 10px; white-space: nowrap; }
.edits-hunk { border-bottom: 1px solid var(--border); }
.edits-hunk.on { box-shadow: inset 2px 0 var(--accent); }
.edits-hunk-head { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 7px 12px; border: 0; background: transparent; color: var(--muted); text-align: left; font: 11px var(--mono); cursor: pointer; }
.edits-hunk-head:hover { background: var(--surface2); }
.edits-hunk-head small { color: var(--faint); font-size: 10px; }
.edits-hunk-head .edits-state { margin-left: auto; font-size: 10px; }
.edits-hunk:not(.on) .diff-patch { opacity: .72; }
.ch-edits-n { margin-left: 6px; color: var(--accent); font: 600 10px var(--mono); }
.ch-edits-n:empty { display: none; }
/* Edits is a full page (pages.js): the code view uses the whole width and the file list scrolls inside it. */
.view:has(.edits-page) { display: grid; overflow: hidden; padding: 0; }
.page.edits-page { height: 100%; padding: 20px 28px; grid-template-rows: auto minmax(0, 1fr); align-content: stretch; gap: 0; }
