/* ── reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #222;
  background: #fafafa;
  display: flex;
  flex-direction: column;
}

/* ── toolbar (shared visual language with the other tabs) ─────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.app-title { font-weight: 700; font-size: 16px; margin-right: 6px; }
.back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: #f0f0f0; color: #444; text-decoration: none;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
  transition: background 0.15s;
}
.back-btn:hover { background: #ddd; }
#toolbar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; }
#toolbar select, #toolbar input[type="search"] {
  padding: 4px 8px; border: 1px solid #ccc; border-radius: 4px;
  font-size: 13px; background: #fff;
}
#toolbar input[type="search"] { width: 160px; }
.stats { font-size: 12px; color: #888; margin-left: auto; }

/* ── metrics bar ──────────────────────────────────────────────────────── */
#metrics-bar {
  display: flex;
  gap: 0;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.metric-pill { text-align: center; padding: 4px 16px; font-size: 12px; line-height: 1.3; }
.metric-pill .val { font-size: 20px; font-weight: 700; }
.metric-pill .lbl { color: #888; }

/* ── before / after split ─────────────────────────────────────────────── */
#main { flex: 1; display: flex; gap: 0; overflow: hidden; }
.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#after-pane { border-left: 2px solid #ececec; }
.pane-heading {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: #888; padding: 10px 18px 8px; flex-shrink: 0;
}
.pane-heading .count { color: #bbb; font-weight: 700; }
#mention-list, #cluster-list { flex: 1; overflow-y: auto; padding: 0 16px 40px; }

/* ── mention card (before) ────────────────────────────────────────────── */
.mention-card {
  border: 1px solid #e6e6e6; border-left: 3px solid #e6e6e6;
  border-radius: 6px; margin-bottom: 5px; background: #fff;
  padding: 7px 11px; font-size: 12.5px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.mention-card:hover { background: #fafafa; }
.mention-card .m-title { font-weight: 600; line-height: 1.35; }
.mention-card .m-meta { color: #999; font-size: 11px; margin-top: 2px; }
.mention-card .m-meta .mid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
/* dim non-selected when a cluster is focused */
#mention-list.focusing .mention-card { opacity: 0.32; }
#mention-list.focusing .mention-card.hl { opacity: 1; }
.mention-card.hl { border-left-color: #1A85FF; background: #1a85ff14; }

/* ── cluster card (after) ─────────────────────────────────────────────── */
.cluster-card {
  border: 1px solid #e0e0e0; border-left: 3px solid #cfcfcf;
  border-radius: 8px; margin-bottom: 6px; background: #fff; overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cluster-card.merged { border-left-color: #00BF7F; }
.cluster-card.review { border-left-color: #D41159; }
.cluster-card.sel { box-shadow: 0 0 0 2px #1A85FF55; border-color: #1A85FF; }
.cluster-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; user-select: none; transition: background 0.12s;
}
.cluster-header:hover { background: #fafafa; }
.cluster-header .arrow { flex-shrink: 0; font-size: 10px; color: #999; transition: transform 0.2s; }
.cluster-card.open .cluster-header .arrow { transform: rotate(90deg); }
.cluster-header .title { flex: 1; font-weight: 600; line-height: 1.35; }
.cluster-header .members-badge {
  flex-shrink: 0; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 700; background: #f0f0f0; color: #777;
}
.cluster-card.merged .cluster-header .members-badge { background: #00bf7f1f; color: #07895d; }

.cluster-detail { display: none; padding: 4px 14px 12px 30px; border-top: 1px solid #f1f1f1; }
.cluster-card.open .cluster-detail { display: block; }
.cluster-detail .desc { font-size: 12.5px; line-height: 1.55; color: #333; margin: 7px 0 9px; }

/* badges & fields */
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge.area  { background: #1a85ff14; color: #1262c4; }
.badge.instr { background: #4f2c9914; color: #4f2c99; }
.badge.body  { background: #00000010; color: #555; }
.badge.status-implemented { background: #00bf7f1f; color: #07895d; }
.badge.status-planned     { background: #ffd40033; color: #8a6d00; }
.badge.status-reversed    { background: #d4115914; color: #b00f4e; }
.badge.status-failed      { background: #ff633320; color: #c23c12; }
.badge.status-incomplete, .badge.status-unknown { background: #00000010; color: #777; }
.badge.review { background: #d4115914; color: #b00f4e; }

.field { margin-bottom: 2px; font-size: 12px; }
.field-label { font-weight: 600; color: #666; }

/* member list inside a cluster */
.members { margin-top: 8px; border-top: 1px dashed #eee; padding-top: 7px; }
.members .m-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #aaa; margin-bottom: 4px; }
.member-row {
  display: flex; align-items: baseline; gap: 8px; padding: 3px 6px; border-radius: 4px;
  font-size: 12px; cursor: pointer;
}
.member-row:hover { background: #1a85ff10; }
.member-row .stage { flex-shrink: 0; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: #1A85FF; min-width: 88px; }
.member-row .mtitle { flex: 1; color: #444; }
.member-row .mid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; color: #bbb; }

.conflicts { margin-top: 8px; font-size: 11.5px; color: #b00f4e; }
.conflicts .c-field { font-weight: 700; }

.loading { display: flex; align-items: center; justify-content: center; height: 80px; color: #999; font-size: 13px; }
.hidden { display: none !important; }
