:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-subtle: #f8f9fb;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #1457d9;
  --accent-soft: #edf3ff;
  --success: #16834b;
  --success-soft: #eaf7ef;
  --warning: #a45a00;
  --warning-soft: #fff5e5;
  --danger: #c43d3d;
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Arial, sans-serif;
}

:root.dark {
  color-scheme: dark;
  --bg: #18191b;
  --surface: #222326;
  --surface-subtle: #292a2e;
  --line: #3b3d43;
  --line-strong: #4c4f57;
  --text: #eceef2;
  --muted: #a4a8b1;
  --accent: #76a6ff;
  --accent-soft: #283650;
  --success: #67d495;
  --success-soft: #223c2e;
  --warning: #f1b55f;
  --warning-soft: #45351f;
  --danger: #ff8585;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, textarea { font: inherit; }
button { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.issues-shell { height: 100vh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.issues-header { min-height: 68px; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
.issues-brand { display: flex; align-items: center; gap: 12px; }
.issues-brand h1 { margin: 0; font-size: 19px; line-height: 1.35; letter-spacing: 0; }
.issues-brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.back-link, .icon-button { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.back-link:hover, .icon-button:hover { background: var(--surface-subtle); border-color: var(--line-strong); }

.summary-strip { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); border-bottom: 1px solid var(--line); background: var(--surface); padding: 0 24px; }
.summary-item { min-height: 66px; border: 0; border-bottom: 2px solid transparent; background: transparent; display: flex; align-items: center; justify-content: center; gap: 9px; cursor: pointer; color: var(--muted); }
.summary-item strong { font-size: 20px; color: var(--text); }
.summary-item:hover { background: var(--surface-subtle); }
.summary-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.summary-item.active strong { color: var(--accent); }

.issues-toolbar { min-height: 62px; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.search-field { width: min(440px, 100%); height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.search-field svg { color: var(--muted); flex: 0 0 auto; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.toolbar-status { color: var(--muted); font-size: 13px; white-space: nowrap; }

.issues-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 38%) minmax(0, 1fr); }
.issue-list-panel { min-height: 0; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.issue-list { display: flex; flex-direction: column; }
.issue-row { width: 100%; min-height: 112px; padding: 16px 20px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; }
.issue-row:hover { background: var(--surface-subtle); }
.issue-row.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.issue-row-top, .issue-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.issue-row h2 { margin: 9px 0 12px; font-size: 15px; line-height: 1.5; letter-spacing: 0; overflow-wrap: anywhere; }
.issue-row-bottom { color: var(--muted); font-size: 12px; }
.reason-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.reason-tag, .status-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 4px; background: var(--surface-subtle); color: var(--muted); font-size: 12px; }
.status-badge[data-status="open"] { color: var(--warning); background: var(--warning-soft); }
.status-badge[data-status="in_progress"] { color: var(--accent); background: var(--accent-soft); }
.status-badge[data-status="resolved"] { color: var(--success); background: var(--success-soft); }

.issue-detail { min-width: 0; padding: 26px 30px 40px; background: var(--bg); overflow: auto; }
.detail-placeholder, .access-state { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.detail-placeholder svg { width: 32px; height: 32px; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.detail-heading h2 { margin: 7px 0 0; font-size: 22px; line-height: 1.5; letter-spacing: 0; overflow-wrap: anywhere; }
.detail-meta { color: var(--muted); font-size: 13px; }
.detail-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 12px; font-size: 14px; }
.answer-box, .retest-result { white-space: pre-wrap; line-height: 1.75; font-size: 14px; overflow-wrap: anywhere; }
.answer-box:empty::before { content: "暂无有效回答"; color: var(--muted); }
.error-box { margin-top: 12px; padding: 10px 12px; border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); font-size: 13px; }
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fields-grid label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 13px; }
textarea { width: 100%; resize: vertical; min-height: 116px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); line-height: 1.55; outline: 0; }
textarea:focus, .search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.retest-result.passed { color: var(--success); }
.retest-result.failed { color: var(--danger); }
.source-list { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.source-chip { padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 12px; }

.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 22px; }
.status-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.button { min-height: 36px; padding: 7px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); cursor: pointer; }
.button:hover { background: var(--surface-subtle); }
.button.primary { background: var(--accent); border-color: var(--accent); color: white; }
.button.quiet { border-color: transparent; color: var(--muted); }
.button:disabled { opacity: .55; cursor: wait; }
.status-button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.status-button.primary.active { color: white; background: var(--success); border-color: var(--success); }

.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.access-state { flex: 1; }
.access-state.denied { color: var(--danger); }
.loading-mark { width: 22px; height: 22px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 10px); padding: 9px 14px; border-radius: 6px; background: #16181d; color: #fff; font-size: 13px; opacity: 0; transition: .18s ease; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .issues-shell { height: auto; min-height: 100vh; overflow: visible; }
  .issues-header, .issues-toolbar { padding-left: 14px; padding-right: 14px; }
  .summary-strip { padding: 0; overflow-x: auto; grid-template-columns: repeat(5, minmax(112px, 1fr)); }
  .issues-workspace { display: block; }
  .issue-list-panel { border-right: 0; }
  .issue-detail { padding: 22px 16px 36px; }
  .fields-grid { grid-template-columns: 1fr; }
  .status-actions { width: 100%; margin-left: 0; }
  .status-actions .button { flex: 1; }
}
