/* 通用组件：按钮、输入框、标签、徽章、卡片、对话框、代码与 diff、提示 */

/* 标签分类颜色 */
[data-g="ver"] { --g-color: var(--g-ver); }
[data-g="conflict"] { --g-color: var(--g-conflict); }
[data-g="owner"] { --g-color: var(--g-owner); }
[data-g="when"] { --g-color: var(--g-when); }
[data-g="div"] { --g-color: var(--g-div); }
[data-g="exc"] { --g-color: var(--g-exc); }
[data-g="env"] { --g-color: var(--g-mismatch); }
/* 归属按取值区分：本 Mod 最需要关注 */
[data-owner="self"] { --g-color: var(--red); }
[data-owner="external"], [data-owner="interaction"] { --g-color: var(--amber); }
[data-owner="game"] { --g-color: var(--blue); }
[data-owner="not_self"], [data-owner="unknown"] { --g-color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px;
  border: 1px solid var(--border-strong); background: var(--raised); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; padding: 0 13px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }
.btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15), inset 0 1px 0 rgba(255, 255, 255, .18), 0 6px 14px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.primary:hover { background: linear-gradient(180deg, var(--accent-hover), var(--accent)); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.small { font-size: 12px; height: 26px; padding: 0 10px; border-radius: 6px; }
.btn.danger { color: var(--red); }
.btn b { font-weight: 600; }
.link { border: 0; background: none; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.link:hover { color: var(--accent-text); }

/* ---------- 输入 ---------- */
.input {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 11px; min-width: 0; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea.input { resize: vertical; line-height: 1.55; }
.search-group .input { width: auto; height: 32px; }
.search-box {
  flex: 1; max-width: 420px; min-width: 160px; height: 32px; display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: 13px; color: var(--text); }
kbd {
  font: 11px var(--mono); color: var(--muted); padding: 0 5px; line-height: 17px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px;
}

/* ---------- 标签（自动分类） ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  font: inherit; font-size: 11.5px; font-weight: 500; line-height: 20px; padding: 0 8px 0 7px; border-radius: 6px;
  color: color-mix(in srgb, var(--g-color, var(--muted)) 78%, var(--text));
  background: color-mix(in srgb, var(--g-color, var(--muted)) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--g-color, var(--muted)) 22%, transparent);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .12s, border-color .12s;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--g-color, var(--muted)); flex-shrink: 0; }
.chip:hover { background: color-mix(in srgb, var(--g-color, var(--muted)) 17%, transparent); border-color: color-mix(in srgb, var(--g-color, var(--muted)) 45%, transparent); }
.chip[data-g="ver"] { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.chip[data-g="conflict"] { font-weight: 600; }
.chip.more { cursor: default; color: var(--muted); background: none; border-color: transparent; padding: 0 4px; }
.chip.more::before { display: none; }

.active-filters {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  margin: 0 12px 8px; padding: 8px 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--border-strong);
}
.active-filters .chip[data-remove]::after { content: "×"; margin-left: 2px; opacity: .6; font-size: 13px; line-height: 1; }
.active-filters .chip[data-remove]:hover::after { opacity: 1; }

/* ---------- 徽章 / 状态 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; line-height: 20px;
  padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); height: 28px;
  padding: 0 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.pill.warn::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.pill.bad::before { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.pill.clickable { cursor: pointer; transition: border-color .15s; }
.pill.clickable:hover { border-color: var(--border-strong); color: var(--text); }

/* ---------- 任务进度 ---------- */
.job {
  display: flex; align-items: center; gap: 14px; padding: 6px 20px; font-size: 12.5px;
  background: var(--accent-soft); color: var(--accent-text); border-bottom: 1px solid var(--border);
}
.job.failed { background: var(--red-soft); color: var(--red); }
.job.done { background: var(--green-soft); color: var(--green); }
.job-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-bar { width: 160px; height: 3px; border-radius: 2px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.job-bar i { display: block; height: 100%; width: 30%; background: currentColor; border-radius: 2px; animation: indeterminate 1.3s ease-in-out infinite; }
.job:not(.running) .job-bar { display: none; }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

/* ---------- 列表卡片 ---------- */
.issue {
  position: relative; padding: 11px 12px 11px 14px; margin-bottom: 2px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; transition: background .12s, border-color .12s;
}
.issue + .issue::after { content: ""; position: absolute; left: 14px; right: 12px; top: -2px; height: 1px; background: var(--border); }
.issue:hover { background: var(--surface-2); }
.issue:hover::after, .issue:hover + .issue::after, .issue.selected::after, .issue.selected + .issue::after { opacity: 0; }
.issue.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.issue.unseen::before { content: ""; position: absolute; left: 5px; top: 18px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.issue-top { display: flex; gap: 9px; align-items: flex-start; }
.issue-top input { margin: 3px 0 0; accent-color: var(--accent); }
.issue h3 { margin: 0; font: 600 13.5px/1.45 var(--display); flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.issue:not(.unseen) h3 { color: var(--text-2); font-weight: 500; }
.issue time { font-size: 11.5px; color: var(--muted); white-space: nowrap; margin-top: 1px; }
.issue-summary { margin: 4px 0 0 22px; font-size: 12.5px; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.issue .chips { margin: 8px 0 0 22px; }
.issue-flags { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 0 22px; }
.mark { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; margin-right: 6px; padding: 0 5px; border-radius: 4px; line-height: 16px; display: inline-block; }
.mark.ai { color: var(--violet); background: var(--violet-soft); }

.cluster-banner {
  margin: 0 12px 8px; padding: 10px 12px; border-radius: var(--radius); font-size: 12.5px;
  background: var(--violet-soft); color: var(--violet); display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  border: 1px solid color-mix(in srgb, var(--violet) 25%, transparent);
}
.cluster-banner span { flex: 1; min-width: 120px; font-weight: 500; }

/* ---------- 空状态 / 骨架 ---------- */
.empty { text-align: center; padding: 90px 24px; color: var(--muted); }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center; font-size: 24px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--accent-text);
}
.empty h2 { color: var(--text); font: 600 17px/1.4 var(--display); margin: 16px 0 6px; }
.empty p { margin: 0 auto 16px; max-width: 360px; }
.skeleton { height: 88px; margin: 0 4px 6px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- 详情 ---------- */
.detail { max-width: 1000px; margin: 0 auto; padding: 26px 32px 60px; animation: fade-in .18s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }
.detail-head { display: flex; flex-direction: column; gap: 10px; }
.detail-head h1 { margin: 0; font: 650 22px/1.35 var(--display); letter-spacing: -.2px; overflow-wrap: anywhere; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); align-items: center; }
.detail-labels { gap: 6px; }
.detail-labels .chip { font-size: 12px; line-height: 22px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.tabs {
  display: inline-flex; gap: 2px; margin: 20px 0 16px; padding: 3px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--border); max-width: 100%; overflow-x: auto;
}
.tab {
  border: 0; background: none; font: inherit; font-size: 13px; color: var(--text-2); padding: 5px 14px; height: 30px;
  border-radius: 7px; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--raised); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tab small { margin-left: 5px; font-size: 11px; color: var(--muted); font-weight: 500; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 10px; font: 600 14px/1.4 var(--display); display: flex; align-items: center; gap: 8px; }
.card h3 .count { font-size: 12px; color: var(--muted); font-weight: 400; }
.card-eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.card-eyebrow > span:first-child { margin-right: 4px; letter-spacing: .3px; }
.card p { margin: 4px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card p.lead { font-size: 14.5px; line-height: 1.7; color: var(--text); }
.bot-card { border-left: 3px solid var(--violet); }
.section-label { font-size: 11px; font-weight: 600; letter-spacing: .6px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }

.hero {
  position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 14px;
  background:
    radial-gradient(600px 160px at 0% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(500px 140px at 100% 0%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow);
}
.hero .summary { font: 600 17px/1.55 var(--display); margin: 2px 0 14px; }
.root-cause { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.root-cause p { margin: 4px 0 6px; white-space: pre-wrap; }
.confidence { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.confidence i { display: inline-block; width: 16px; height: 5px; border-radius: 3px; background: var(--surface-3); }
.confidence i:last-of-type { margin-right: 4px; }
.confidence.high i { background: var(--green); }
.confidence.medium i:nth-child(-n+2) { background: var(--amber); }
.confidence.low i:first-child { background: var(--red); }

.fix { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: var(--surface-2); }
.fix-title { display: flex; gap: 10px; align-items: baseline; font-weight: 600; }
.fix-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; flex-shrink: 0; }
.fix ol { margin: 8px 0 6px; padding-left: 50px; }
.fix .files { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 32px; }
.file-chip { font: 12px var(--mono); padding: 1px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }

.claims { list-style: none; margin: 0; padding: 0; }
.claims li { padding: 8px 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.claims li:last-child { border-bottom: 0; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ref { font: 11.5px var(--mono); color: var(--accent-text); background: var(--accent-soft); padding: 0 6px; border-radius: 4px; cursor: pointer; }
.ref:hover { text-decoration: underline; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.callout { display: flex; gap: 12px; align-items: center; padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; border: 1px solid transparent; }
.callout > div { flex: 1; }
.callout.warn { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 22%, transparent); }
.callout.error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 22%, transparent); }
.callout.info { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.callout.ai { background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 22%, transparent); }
.callout .btn { flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--red); font-size: 13px; min-height: 1em; margin-top: 8px; }

details.fold { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
details.fold > summary { cursor: pointer; padding: 9px 14px; font-weight: 500; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "›"; transition: transform .15s; color: var(--muted); }
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold > .fold-body { padding: 0 14px 12px; }
.card details.fold { background: var(--surface-2); }

/* ---------- 代码 / diff ---------- */
pre, code { font-family: var(--mono); font-size: 12.5px; }
pre.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; overflow: auto; max-height: 480px; line-height: 1.55; }
:not(pre) > code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.diff { padding: 8px 0; }
.diff span { display: block; padding: 0 12px; white-space: pre; }
.diff .add { background: var(--diff-add); color: var(--diff-add-text); }
.diff .del { background: var(--diff-del); color: var(--diff-del-text); }
.diff .hunk { background: var(--diff-hunk); color: var(--accent-text); }
.diff .meta { color: var(--muted); font-weight: 600; }
.code-wrap { position: relative; }
.code-wrap .copy { position: absolute; right: 8px; top: 8px; opacity: .85; }

/* ---------- 原始日志 ---------- */
.logs { display: grid; grid-template-columns: 230px 1fr; gap: 12px; min-height: 420px; }
.doc-list { display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow-y: auto; }
.doc-item { text-align: left; border: 1px solid transparent; background: none; font: inherit; font-size: 12.5px; color: var(--text-2);
  padding: 7px 10px; border-radius: 8px; cursor: pointer; overflow-wrap: anywhere; }
.doc-item:hover { background: var(--surface-3); }
.doc-item.active { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.doc-item small { display: block; color: var(--muted); font-size: 11px; }
.viewer { display: flex; flex-direction: column; min-width: 0; }
.viewer-bar { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.viewer-bar .input { max-width: 260px; }
.log-view { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 70vh; overflow: auto; margin: 0; padding: 6px 0; line-height: 1.6; }
.log-view span { display: block; padding: 0 12px 0 0; white-space: pre; }
.log-view span::before { content: attr(data-n); display: inline-block; width: 52px; padding-right: 12px; text-align: right; color: var(--muted); opacity: .6; user-select: none; }
.log-view .target { background: var(--amber-soft); }
.log-view mark { background: var(--amber); color: #000; border-radius: 2px; }
@media (max-width: 900px) { .logs { grid-template-columns: 1fr; } }

/* ---------- 环境对比 ---------- */
.env-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.env-grid pre { max-height: 240px; }

/* ---------- 时间线 ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.timeline li.bad::before { border-color: var(--red); }
.timeline li.good::before { border-color: var(--green); }
.timeline b { font-weight: 600; }
.timeline small { color: var(--muted); margin-left: 6px; }
.timeline p { margin: 2px 0 0; color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- AI 对话 ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; }
.chat-log { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg .avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; flex-shrink: 0; font-weight: 700; }
.msg.assistant .avatar { background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; }
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: var(--surface-3); color: var(--text-2); }
.bubble { padding: 10px 14px; border-radius: 14px; min-width: 0; max-width: min(760px, 88%); overflow-wrap: anywhere; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; box-shadow: var(--shadow-sm); }
.msg.user .bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; white-space: pre-wrap; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h4 { margin: 10px 0 6px; font-size: 14px; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 22px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; padding: 4px 12px; border-radius: 999px; cursor: pointer; transition: border-color .12s, color .12s; }
.quick button:hover { border-color: var(--accent); color: var(--accent-text); }
.composer { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 4px; }
.composer textarea { flex: 1; }

/* ---------- 对话框 ---------- */
.dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; width: min(720px, 94vw); max-height: 90vh; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.dialog.narrow { width: min(560px, 94vw); }
.dialog::backdrop { background: rgba(8, 9, 12, .5); backdrop-filter: blur(4px); }
.dialog form { display: flex; flex-direction: column; max-height: 90vh; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 10px; }
.dialog-head h2 { margin: 0; font: 600 17px/1.4 var(--display); }
.dialog-body { padding: 4px 20px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.members-note { margin: 8px 0 4px; font-size: 12.5px; }
.members-table-wrap { overflow-x: auto; }
.members-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.members-table th, .members-table td { text-align: left; vertical-align: middle; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.members-table th { color: var(--muted); font-weight: 500; }
.members-table th:first-child, .members-table td:first-child { padding-left: 0; }
.members-table th:last-child, .members-table td:last-child { text-align: right; padding-right: 0; }
.members-table td:not(:first-child) { white-space: nowrap; }
.member-id { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
#member-form { gap: 12px; }
#members-dialog h3 { margin: 12px 0 0; font-size: 14px; }
.member-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.member-actions label { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.source-commit { margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.dialog-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.spacer { flex: 1; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 12px; margin: 0; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid label, .dialog-body > label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.span-2 { grid-column: span 2; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--text); }
.check input { accent-color: var(--accent); }
.hint { font-size: 11.5px; }
.sync-hint { margin: 0; align-self: end; padding-bottom: 6px; }
.hint.ok { color: var(--green); }
.guide { margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.guide summary { cursor: pointer; color: var(--accent-text); }
.guide ol { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

.stage-picker, .picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stage-picker input, .picker input { position: absolute; opacity: 0; pointer-events: none; }
.stage-picker span, .picker span { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 4px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; transition: border-color .12s, background .12s; }
.stage-picker span:hover, .picker span:hover { border-color: var(--border-strong); }
.stage-picker small, .picker small { font-weight: 400; font-size: 11px; color: var(--muted); }
.stage-picker input:checked + span, .picker input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.stage-picker input:focus-visible + span, .picker input:focus-visible + span { box-shadow: var(--ring); }
@media (max-width: 600px) { .stage-picker, .scope-picker { grid-template-columns: repeat(2, 1fr); } }
.picker { grid-template-columns: repeat(4, 1fr); }
.picker input:disabled + span { opacity: .45; cursor: not-allowed; }
.analyze-preview { margin: 4px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.analyze-preview b { font-variant-numeric: tabular-nums; color: var(--accent-text); }
.dialog:not(.show-fix) .fix-only { display: none; }

/* ---------- 提示 ---------- */
.toasts { position: fixed; inset: auto 20px 20px auto; margin: 0; padding: 0; border: 0; background: transparent;
  width: max-content; max-width: calc(100vw - 40px); overflow: visible; display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toasts[popover]:not(:popover-open) { display: none; }
.toast { min-width: min(240px, calc(100vw - 40px)); max-width: min(420px, calc(100vw - 40px)); overflow-wrap: anywhere; padding: 10px 14px 10px 36px; border-radius: var(--radius); background: var(--raised); color: var(--text); position: relative;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s ease-out; }
.toast::before { content: ""; position: absolute; left: 14px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toast.error::before { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.toast.success::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- 列表顶部：是不是本 Mod 的问题 ---------- */
.blame-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin: 0 12px 10px; padding: 3px;
  border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border);
}
.blame {
  --dot: var(--muted);
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0;
  border: 0; background: none; font: inherit; cursor: pointer; padding: 5px 9px 6px; border-radius: 7px;
  color: var(--text-2); transition: background .12s, color .12s;
}
.blame span { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.blame span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex-shrink: 0; }
.blame[data-blame=""] span::before { display: none; }
.blame b { font: 650 16px/1.2 var(--display); color: var(--text); font-variant-numeric: tabular-nums; }
.blame:hover { color: var(--text); }
.blame.active { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.blame.active b { color: var(--dot); }
.blame[data-blame=""].active b { color: var(--text); }
.blame[data-blame="ours"] { --dot: var(--red); }
.blame[data-blame="not_ours"] { --dot: var(--green); }
.blame[data-blame="undecided"] { --dot: var(--muted); }

/* ---------- 简要 ---------- */
.brief {
  padding: 14px 18px; margin-bottom: 14px; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
}
.brief p { margin: 0; font-size: 14.5px; line-height: 1.75; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- AI 用量 ---------- */
.dialog-shell { display: flex; flex-direction: column; max-height: 90vh; }
.dialog-shell .dialog-body { padding-bottom: 18px; }
.usage-tabs { margin: 0 0 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font: 600 22px/1.3 var(--font); color: var(--text); margin-top: 2px; }
.stat-note { font-size: 11.5px; color: var(--text-2); margin-top: 4px; line-height: 1.45; }
.meter { height: 4px; border-radius: 4px; background: var(--accent-soft); margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.usage-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.usage-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--text); }
.usage-table tr:last-child td { border-bottom: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.daily { position: relative; display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; height: 140px; padding-top: 8px;
  border-bottom: 1px solid var(--border); }
.daily .col { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; cursor: default; outline: none; }
.daily .col i { display: block; width: min(24px, 70%); background: var(--accent); border-radius: 4px 4px 0 0; transition: opacity .12s; }
.daily .col span { position: absolute; bottom: -18px; font-size: 10.5px; color: var(--muted); }
.daily .col:hover i, .daily .col:focus-visible i { opacity: .75; }
.daily { margin-bottom: 22px; }
.chart-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); white-space: nowrap; pointer-events: none; z-index: 2;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 6px 10px; font-size: 12px; }

.mode-picker { grid-template-columns: repeat(2, 1fr); }
.mode-picker span { align-items: flex-start; text-align: left; padding: 10px 12px; }
