/* ==========================================================================
   CM Code Review - 代码审查界面（GitHub Code Review 风格，主题变量驱动）
   ========================================================================== */
#cm-review-app { max-width: 1160px; margin: 0 auto; }

.cr-wrap { padding: 8px 0 40px; }

/* ---------- 按钮 ---------- */
.cr-btn, .cr-btn-primary {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
    font-size: 0.88rem; background: var(--bg-soft); color: var(--text-bright);
    transition: background .15s, border-color .15s, transform .1s;
}
.cr-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.cr-btn:active { transform: scale(0.97); }
.cr-btn-primary {
    background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.cr-btn-primary:hover { filter: brightness(1.1); }
.cr-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 上传 ---------- */
.cr-head { margin-bottom: 20px; }
.cr-head h2 { margin: 0 0 6px; font-size: 1.45rem; color: var(--text-bright); }
.cr-sub { margin: 0; font-size: 0.85rem; color: var(--text-dim); }
.cr-upload {
    max-width: 760px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 22px;
}
.cr-field { margin-bottom: 16px; }
.cr-field label { display: block; font-size: 0.85rem; color: var(--text-bright); margin-bottom: 6px; font-weight: 600; }
.cr-field input[type="text"], .cr-field textarea, .cr-field select {
    width: 100%; box-sizing: border-box; padding: 10px 12px;
    background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-bright); font-family: var(--font-mono); font-size: 0.88rem;
    transition: border-color .15s;
}
.cr-field input:focus, .cr-field textarea:focus, .cr-field select:focus {
    border-color: var(--accent); outline: none;
}
.cr-field textarea { resize: vertical; line-height: 1.5; }
.cr-field input[type="file"] { font-size: 0.85rem; padding: 0; background: none; border: none; }
.cr-limit-hint { font-size: 0.8rem; color: var(--text-dim); margin: 4px 0 16px; }
.cr-loading, .cr-error, .cr-empty { padding: 40px; text-align: center; color: var(--text-dim); }
.cr-error { color: var(--danger, #f85149); }

/* ---------- 审查头部 ---------- */
.cr-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cr-head-left h2 { font-size: 1.35rem; margin: 0 0 8px; color: var(--text-bright); word-break: break-word; }
.cr-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-dim); }
.cr-badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
    border-radius: 999px; font-size: 0.75rem; font-weight: 600;
    background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-bright);
}
.cr-badge.cr-badge-owner { background: rgba(88, 166, 255, 0.12); border-color: rgba(88, 166, 255, 0.4); color: var(--accent); }
.cr-timer {
    font-size: 0.9rem; font-weight: 700; color: var(--accent);
    background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 14px; white-space: nowrap; font-family: var(--font-mono);
}
.cr-timer.cr-timer-warn { color: #f0883e; }

/* ---------- 工具栏 ---------- */
.cr-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cr-tip { font-size: 0.82rem; color: var(--text-dim); }
.cr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 主体 ---------- */
.cr-body { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.cr-code-pane {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    overflow: auto; max-height: 74vh;
}
.cr-code { min-width: max-content; padding: 8px 0; }
.cr-line {
    display: flex; align-items: stretch; position: relative; line-height: 1.55;
    font-family: var(--font-mono); font-size: 0.84rem;
    transition: background .08s;
}
.cr-line:hover { background: var(--bg-hover); }
.cr-ln {
    flex: none; width: 54px; text-align: right; padding-right: 14px; padding-top: 1px; user-select: none;
    color: var(--text-dim); opacity: .55; font-size: 0.78rem; line-height: 1.6;
    background: transparent;
}
.cr-add {
    flex: none; width: 22px; margin: 0 2px 0 0; padding: 0; border: none; background: transparent;
    color: var(--text-dim); cursor: pointer; font-size: 0.95rem; line-height: 1.6; opacity: 0;
    transition: opacity .12s; align-self: center;
}
.cr-line:hover .cr-add { opacity: 1; }
.cr-add:hover { color: var(--accent); }
.cr-line.cr-has-comment .cr-ln { color: var(--accent); opacity: 1; font-weight: 700; }
.cr-code-line { flex: 1; white-space: pre; padding-right: 16px; color: var(--text-bright); background: transparent; padding-top: 1px; }

/* ---------- 评论输入 ---------- */
.cr-comment-input {
    margin: 8px 8px 8px 54px; padding: 12px; background: var(--bg-soft);
    border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.cr-ci-head { font-size: 0.78rem; color: var(--accent); margin-bottom: 8px; font-weight: 600; }
.cr-comment-input textarea {
    width: 100%; box-sizing: border-box; padding: 8px 10px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text-bright);
    font-family: var(--font-mono); font-size: 0.85rem; resize: vertical; line-height: 1.5;
}
.cr-ci-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }

/* ---------- 侧栏 ---------- */
.cr-side { position: sticky; top: 70px; max-height: 74vh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.cr-side-title {
    font-size: 0.8rem; font-weight: 700; color: var(--text-bright); margin: 0;
    text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 8px;
}
.cr-count-pill {
    background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 8px;
    font-size: 0.72rem; font-weight: 700;
}
.cr-comments { display: flex; flex-direction: column; gap: 12px; }
.cr-comment-group { border-left: 3px solid var(--border); padding-left: 12px; }
.cr-cg-line { font-size: 0.75rem; color: var(--accent); margin-bottom: 6px; font-weight: 600; }
.cr-comment {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 8px;
}
.cr-c-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cr-avatar {
    flex: none; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--accent); color: #fff; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
}
.cr-c-name { display: flex; flex-direction: column; }
.cr-c-name b { font-size: 0.82rem; color: var(--text-bright); line-height: 1.2; }
.cr-c-name span { font-size: 0.7rem; color: var(--text-dim); }
.cr-c-body { font-size: 0.85rem; color: var(--text-bright); word-break: break-word; white-space: pre-wrap; margin-top: 4px; }
.cr-invites { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-invitee {
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem;
    background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; color: var(--text-bright);
}

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
    .cr-body { grid-template-columns: 1fr; }
    .cr-side { position: static; max-height: none; }
    .cr-code-pane { max-height: 60vh; }
    .cr-ln { width: 42px; padding-right: 10px; }
    .cr-comment-input { margin-left: 42px; }
    .cr-head-row { flex-direction: column; }
}

/* ---------- 示例代码 + 审计文档 ---------- */
.cr-sample-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cr-sample-hint { font-size: 0.78rem; color: var(--accent); }
.cr-docs {
    margin-top: 18px; max-width: 760px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
}
.cr-docs h3 { margin: 0 0 12px; font-size: 1.05rem; color: var(--text-bright); }
.cr-docs ul { margin: 0; padding-left: 20px; }
.cr-docs li { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 8px; line-height: 1.6; }
.cr-docs li b { color: var(--text-bright); }
.cr-docs li.cr-warn { color: #f0883e; }
.cr-docs li.cr-warn b { color: #f0883e; }

/* ---------- 下载审计记录 ---------- */
.cr-downloads { margin-top: 20px; }
.cr-downloads .cr-side-title { margin-bottom: 12px; }
.cr-downloads-list { overflow-x: auto; }
.cr-dl-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.cr-dl-table th, .cr-dl-table td {
    padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border);
    color: var(--text-bright); white-space: nowrap;
}
.cr-dl-table th { color: var(--text-dim); font-weight: 600; background: var(--bg-soft); }
.cr-dl-table tr:hover td { background: var(--bg-hover); }
.cr-dl-ip { font-family: var(--font-mono); color: var(--text-dim); }
@media (max-width: 860px) {
    .cr-dl-table th:nth-child(3), .cr-dl-table td:nth-child(3) { display: none; }
}
