/* ============================================================================
   Master/detail, panels, score rows, diff viewer
   ========================================================================== */

.master-detail {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
    min-height: 600px;
}
.master-panel {
    border-right: var(--border-width) solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}
.detail-panel {
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}
.commit-item {
    padding: var(--space-5) var(--space-7);
    border-bottom: var(--border-width) solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.commit-item:hover { background: var(--surface-hover); }
.commit-item.active { background: var(--brand-soft); border-left: var(--border-accent) solid var(--brand); }
.commit-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}
.commit-item-msg {
    font-size: var(--text-base);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: var(--leading-tight);
}
.commit-item-meta {
    display: flex;
    gap: var(--space-4);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-2);
}
.commit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6);
    font-size: var(--text-sm);
    color: var(--text-body);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6) var(--space-8);
    border-bottom: var(--border-width) solid var(--border-subtle);
    background: var(--surface-alt);
}
.panel-section {
    padding: var(--space-7) var(--space-8);
    border-bottom: var(--border-width) solid var(--border-subtle);
}
.panel-section:last-child { border-bottom: none; }
.panel-section-title {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

/* Score rows with rationale */
.score-row {
    padding: var(--space-4) 0;
    border-bottom: var(--border-width) solid var(--border-subtle);
}
.score-row:last-child { border-bottom: none; }
.score-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.score-row-label {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text);
}
.score-row-label i { width: var(--space-9); color: var(--text-body); }
.score-rationale {
    font-size: var(--text-md);
    color: var(--text-body);
    line-height: var(--leading-relaxed);
    margin-top: var(--space-2);
    padding-left: 22px;
}

.diff-viewer {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}
.diff-line { padding: var(--space-px) var(--space-6); white-space: pre; }
.diff-add { background: var(--diff-add-bg); color: var(--diff-add-text); }
.diff-del { background: var(--diff-del-bg); color: var(--diff-del-text); }
.diff-hunk { background: var(--diff-hunk-bg); color: var(--diff-hunk-text); font-weight: var(--weight-semibold); }
.diff-ctx { color: var(--text-body); }
/* The page's own note that it stopped rendering, not a line of the diff. Wraps, because it is a
   sentence and every other diff line is pre-formatted. */
.diff-truncated {
    white-space: normal;
    color: var(--text-muted);
    font-style: italic;
    border-top: var(--border-width) solid var(--border-color);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
}

.diff-header { display: flex; align-items: center; justify-content: space-between; }
.diff-tabs {
    display: inline-flex;
    gap: var(--space-1);
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
    padding: var(--space-1);
}
.diff-tab {
    border: none;
    background: transparent;
    color: var(--text-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    padding: var(--space-2) var(--space-6);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.diff-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Per-file diff: content left, file list right */
.diff-layout { display: flex; align-items: flex-start; }
.diff-content { flex: 1; min-width: 0; max-height: 600px; overflow-y: auto; }
.diff-content .diff-viewer { max-height: none; overflow-y: visible; }
.diff-file { border-bottom: var(--border-width) solid var(--border); }
.diff-file:last-child { border-bottom: none; }
.diff-file-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--diff-file-bg);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}
.diff-file-path {
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-weight: var(--weight-semibold);
    word-break: break-all;
}
.diff-file-stat { font-weight: var(--weight-semibold); }
.diff-add-stat { color: var(--diff-add-text); }
.diff-del-stat { color: var(--diff-del-text); }

.diff-filelist {
    flex: 0 0 240px;
    border-left: var(--border-width) solid var(--border);
    max-height: 600px;
    overflow-y: auto;
    background: var(--surface-alt);
}
.diff-filelist-title {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: var(--border-width) solid var(--border);
}
.diff-filelist-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-sm);
    text-decoration: none;
    color: var(--text-body);
    border-bottom: var(--border-width) solid var(--border-subtle);
}
.diff-filelist-item:hover { background: var(--surface-hover); }
.diff-filelist-item.active { background: var(--diff-active-bg); }
.diff-filelist-path {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    text-align: left;
    font-family: var(--font-mono);
}
.diff-filelist-stats { flex: 0 0 auto; font-weight: var(--weight-semibold); white-space: nowrap; }

/* The full commit message, rendered as authored. */
.commit-message {
    font-size: var(--text-lg);
    line-height: var(--leading-normal);
    color: var(--text);
    white-space: pre-wrap;
}

/* The collapsible metadata strip above a generated report. */
.report-meta {
    padding: var(--space-4) var(--space-9);
    background: var(--surface-alt);
    border-bottom: var(--border-width) solid var(--border-subtle);
    font-size: var(--text-sm);
    color: var(--text-muted);
}
