/* Task diff viewer (/tasks/:id/diff): file tree left, side-by-side pane
   right. Server-rendered — no JS beyond the turbo frame swap. */
@layer components {
  .diff-page {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
  }

  .diff-page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
  }

  .diff-back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
  }

  .diff-back:hover {
    color: var(--ink);
  }

  .diff-page-title {
    margin: 0;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
  }

  .diff-attachment-name {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--muted);
    font-family: var(--font-mono, ui-monospace, monospace);
  }

  .diff-layout {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .diff-tree {
    flex: 0 0 16rem;
    position: sticky;
    top: 0.75rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-control);
    background: var(--surface);
    padding: 0.6rem;
  }

  .diff-tree h4 {
    margin: 0 0 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-2);
  }

  .diff-tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }

  .diff-tree-file {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.45rem;
    border-radius: var(--radius-control);
    text-decoration: none;
    color: var(--ink);
    font-size: 0.82rem;
  }

  .diff-tree-file:hover {
    background: color-mix(in srgb, var(--surface-border) 40%, transparent);
  }

  .diff-tree-file.is-active {
    background: color-mix(in srgb, #4f6a8a 14%, transparent);
  }

  .diff-tree-path {
    font-family: var(--font-mono, ui-monospace, monospace);
    overflow-wrap: anywhere;
    min-width: 0;
  }

  .diff-tree-dir {
    color: var(--muted-2);
  }

  .diff-tree-counts {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .diff-count-add { color: #1f8a4c; }
  .diff-count-del { color: #b3324b; }

  .diff-pane {
    flex: 1;
    min-width: 0;
  }

  .diff-file {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-control);
    background: var(--surface);
    overflow: hidden;
  }

  .diff-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--surface-border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }

  .diff-file-header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    overflow-wrap: anywhere;
  }

  .diff-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-family: var(--font-sans, sans-serif);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .diff-badge--new { background: #e6ffec; color: #1f8a4c; }
  .diff-badge--deleted { background: #ffebe9; color: #b3324b; }

  .diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.78rem;
    line-height: 1.45;
    table-layout: fixed;
  }

  .diff-col-no { width: 3.2rem; }
  .diff-col-code { width: calc(50% - 3.2rem); }

  .diff-hunk td {
    padding: 0.25rem 0.75rem;
    background: color-mix(in srgb, #4f6a8a 8%, transparent);
    color: var(--muted);
    font-size: 0.72rem;
  }

  .diff-no {
    padding: 0 0.4rem;
    text-align: right;
    vertical-align: top;
    color: var(--muted-3, var(--muted-2));
    user-select: none;
    font-variant-numeric: tabular-nums;
    border-right: 1px solid color-mix(in srgb, var(--surface-border) 60%, transparent);
  }

  .diff-code {
    padding: 0 0.6rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    vertical-align: top;
  }

  .diff-no--add, .diff-code--add { background: #e6ffec; }
  .diff-no--del, .diff-code--del { background: #ffebe9; }
  .diff-no--empty, .diff-code--empty { background: color-mix(in srgb, var(--surface-border) 25%, transparent); }

  .diff-empty {
    margin: 0;
    padding: 1.5rem;
    color: var(--muted);
    text-align: center;
  }

  /* The dialog's attachment list. */
  .task-dialog-attachments h4 {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }

  .task-attachments {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
  }

  .task-attachments li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .task-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    overflow-wrap: anywhere;
  }

  .task-attachment-size {
    font-size: 0.75rem;
    color: var(--muted-2);
    white-space: nowrap;
  }

  /* Small screens: tree above pane, both full width. */
  @media (max-width: 56rem) {
    .diff-layout {
      flex-direction: column;
    }

    .diff-tree {
      position: static;
      flex: none;
      width: 100%;
      max-height: 14rem;
    }
  }
}
