/* Brand Brain graph: port of Cortex /graph (brand-graph.js) */
.cg { display: block; }
.cg-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; flex-wrap: wrap; }
.cg-filter, .cg-search { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-2); font-size: 14px; }
.cg-filter { width: 194px; }
.cg-filter select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font: inherit; color: var(--ink); flex: 1; height: 100%; padding: 0 18px 0 0; cursor: pointer; outline: none; }
.cg-filter > svg:last-child { position: absolute; right: 12px; pointer-events: none; color: var(--muted); }
.cg-filter:focus-within, .cg-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cg-fi { display: inline-flex; color: var(--muted); }
.cg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin: 0 2px; }
.cg-search { width: 226px; color: var(--muted); }
.cg-search input { border: 0; outline: none; background: transparent; font: inherit; color: var(--ink); flex: 1; min-width: 0; height: 100%; }
.cg-sp { flex: 1; }
.cg-ask { border-radius: var(--r-pill); }
.cg-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.cg-card, .cg-recs { background: var(--surface); border-radius: 18px; box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12); overflow: hidden; }
.cg-scene { position: relative; height: 660px; touch-action: none; overflow: hidden; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--accent) 5%, var(--surface)) 0%, var(--surface) 76%); }
.cg-scene canvas { display: block; position: absolute; inset: 0; }
.cg-pills { position: absolute; inset: 0; z-index: 10; overflow: hidden; pointer-events: none; }
.cg-pill { position: absolute; left: 0; top: 0; max-width: 192px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 2px 8px; font-size: 12px; line-height: 16px; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }
.cg-pill.quiet { color: var(--ink-2); }
.cg-cap { position: absolute; left: 16px; bottom: 12px; z-index: 10; margin: 0; font-size: 14px; color: var(--ink-2); pointer-events: none; }
.cg-reset { position: absolute; right: 12px; top: 12px; z-index: 11; border-radius: var(--r-pill); }
.cg-tl { position: absolute; left: 12px; top: 12px; z-index: 11; display: flex; align-items: center; gap: 8px; }
.cg-tl[hidden] { display: none; }
.cg-tl .btn { border-radius: var(--r-pill); }
.cg-tl-l { font-size: 12.5px; color: var(--ink); }
.cg-loading, .cg-fail { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; }
.cg-tip { position: absolute; z-index: 12; width: 288px; max-width: calc(100% - 16px); padding: 12px 14px; border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 12px 32px -12px rgba(16, 24, 40, .25); pointer-events: none; }
.cg-tip[hidden] { display: none; }
.cg-tip-k { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.cg-tip-k i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cg-tip b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; font-weight: 600; color: var(--ink); }
.cg-tip p:last-child { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.cg-recs header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 22px 24px 12px; }
.cg-recs header b { font-size: 17px; font-weight: 600; }
.cg-list { max-height: 592px; overflow-y: auto; }
.cg-row { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; padding: 14px 24px 14px 16px; border-top: 1px solid var(--line); background: transparent; }
.cg-row:hover { background: var(--surface-2); }
.cg-row.on { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.cg-ti { flex: none; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; color: var(--c); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.cg-ti svg.i { width: 18px; height: 18px; }
.cg-rt { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 3px; }
.cg-rt b { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cg-rd { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.cg-src { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.cg-flag { color: var(--amber-ink, #9a6a00); font-weight: 500; }
.cg-empty { padding: 18px 24px; margin: 0; }
@media (max-width: 1100px) { .cg-grid { grid-template-columns: 1fr; } .cg-list { max-height: 480px; } }
@media (max-width: 760px) {
  .cg-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .cg-filter, .cg-search { width: 100%; height: 46px; min-height: 46px; box-sizing: border-box; }
  .cg-filter select, .cg-search input { height: 44px; min-height: 44px; }
  .cg-sp { display: none; }
  .cg-ask { align-self: flex-end; min-height: 44px; }
  .cg-scene { height: 384px; }
  .cg-reset, .cg-tl .btn { min-height: 44px; }
  .cg-cap { font-size: 13px; }
  .cg-row { padding: 14px 16px; min-height: 64px; }
}

/* Editable, feedable Brain: panel tabs, fact editor, sources, media, Add knowledge */
.cg-recs header .cg-tabs { flex: none; }
.cg-tabs button { height: 32px; padding: 0 12px; font-size: 13px; }
.cg-pill.pin { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); font-weight: 600; }
.cg-tip-img { display: block; width: 100%; height: 112px; object-fit: cover; border-radius: 8px; margin-top: 8px; }
.cg-ti.img { padding: 0; overflow: hidden; box-shadow: inset 0 0 0 2px var(--c); }
.cg-ti.img img { width: 100%; height: 100%; object-fit: cover; }
.cg-bs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cg-b { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.cg-b.pin { background: var(--accent-soft); color: var(--accent-text); }
.cg-b.bad { background: #FDECEC; color: #B42318; }
.cg-b.old { background: #FBF0D9; color: #8a6012; }
.cg-row.st-wrong b { text-decoration: line-through; color: var(--muted); }
.cg-row.st-outdated b { color: var(--ink-2); }
.cg-ed { padding: 4px 20px 20px; }
.cg-back { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px 0 4px; margin: 0 0 6px -4px; border-radius: 8px; font-size: 13px; color: var(--ink-2); background: transparent; }
.cg-back:hover { background: var(--surface-2); }
.cg-ed-k { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.cg-ed-k i { width: 8px; height: 8px; border-radius: 50%; }
.cg-ed-img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; margin-bottom: 12px; box-shadow: 0 0 0 1px var(--line); }
.cg-lab { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cg-lab input, .cg-lab textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink); background: var(--surface); resize: vertical; }
.cg-lab input:focus, .cg-lab textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cg-ed-t { font-weight: 600 !important; }
.cg-ed-src { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.cg-ed-src img, .cg-src-logo img { width: 18px; height: 18px; border-radius: 4px; object-fit: contain; }
.cg-ed-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cg-tg { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.cg-tg:hover { background: var(--surface-2); }
.cg-tg[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.cg-tg.bad[aria-pressed="true"] { background: #FDECEC; color: #B42318; }
.cg-ed-sec { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.cg-ed-sec > b { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.cg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-chip { display: inline-flex; align-items: center; height: 30px; border-radius: 999px; background: var(--surface-3); font-size: 12.5px; color: var(--ink-2); overflow: hidden; }
.cg-chip button { height: 100%; padding: 0 6px 0 10px; background: transparent; color: inherit; font: inherit; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-chip button + button { padding: 0 8px 0 2px; color: var(--muted); }
.cg-chip button:hover { color: var(--ink); }
.cg-chip.add { padding: 0 10px; gap: 4px; border: 1px dashed var(--line-strong, #C9CDD5); background: transparent; color: var(--accent-text); font-weight: 600; cursor: pointer; }
.cg-merge { display: flex; gap: 6px; }
.cg-merge select { flex: 1; min-width: 0; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; background: var(--surface); }
.cg-hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12.5px; color: var(--muted); }
.cg-hist li > b { color: var(--ink); font-weight: 600; }
.cg-hist li > span:last-child { display: block; color: var(--ink-2); }
.cg-ed-save { margin-top: 14px; }
.cg-guard { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #FEF7E8; box-shadow: inset 0 0 0 1px #F2DDAE; font-size: 13px; color: var(--ink-2); }
.cg-guard b { display: flex; align-items: center; gap: 6px; color: #7a520c; font-size: 13px; }
.cg-guard p { margin: 4px 0 8px; line-height: 1.45; }
.cg-guard div { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-guard.sm { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; padding: 6px 8px; font-size: 12px; }
.cg-src-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 20px 14px 16px; border-top: 1px solid var(--line); }
.cg-src-logo { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--accent-text); }
.cg-src-logo img { width: 22px; height: 22px; }
.cg-src-row .cg-rt { flex: 1; padding-top: 0; }
.cg-src-c { font-size: 12.5px; color: var(--ink-2); }
.cg-src-r { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.cg-src-more { display: flex; align-items: center; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--accent-text); }
.cg-shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.cg-shot { display: flex; flex-direction: column; text-align: left; border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.cg-shot.pin { box-shadow: 0 0 0 2px var(--accent); }
.cg-shot img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); }
.cg-shot > span { padding: 8px 10px; min-width: 0; }
.cg-shot b { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-shot span span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-shelf-add { margin: 4px 16px 16px; }
.cg-linkbar { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 12; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 8px 8px 8px 14px; border-radius: 999px; background: var(--inv-bg); color: var(--inv-ink); font-size: 13px; box-shadow: 0 10px 28px -12px rgb(14 17 22 / .4); }
.cg-linkbar[hidden] { display: none; }
.cg-linkbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgb(14 17 22 / .38); }
.cg-modal[hidden] { display: none; }
.cg-dlg { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: 0 24px 64px -20px rgb(14 17 22 / .45); }
.cg-dh { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 8px; }
.cg-dh h3 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.cg-dh p { margin: 0; }
.cg-modes { margin: 8px 20px 0; display: flex; }
.cg-modes button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; }
.cg-in { padding: 16px 20px 4px; }
.cg-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border: 1.5px dashed var(--line-strong, #C9CDD5); border-radius: 12px; text-align: center; cursor: pointer; color: var(--accent-text); }
.cg-drop b { color: var(--ink); font-size: 14px; }
.cg-sample, .cg-mic { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin-top: 10px; padding: 0 12px; border-radius: 999px; background: var(--surface-3); font-size: 13px; color: var(--ink-2); }
.cg-mic.on { background: #FDECEC; color: #B42318; animation: cg-pulse 1s ease-in-out infinite; }
@keyframes cg-pulse { 50% { box-shadow: 0 0 0 6px rgb(180 35 24 / .12); } }
.cg-df { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; }
.cg-reading { display: flex; gap: 14px; padding: 24px 20px; }
.cg-reading b { font-size: 15px; }
.cg-rev { padding: 6px 20px 0; display: grid; gap: 8px; }
.cg-ri { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); }
.cg-ri input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.cg-ri .cg-rt { flex: 1; padding: 0; }
.cg-ri .meta { font-size: 12.5px; line-height: 1.45; }
.cg-ri select { flex: none; max-width: 150px; height: 30px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 12.5px; background: var(--surface); }
.cg-ri.conflict { box-shadow: inset 0 0 0 1px #F2DDAE; background: #FFFCF5; }
.cg-ri.rel { padding: 8px 12px; }
.cg-rh { margin: 10px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); }
@media (max-width: 760px) {
  .cg-recs header { flex-wrap: wrap; }
  .cg-tabs button { height: 44px; }
  .cg-tg, .cg-chip, .cg-back, .cg-sample, .cg-mic, .cg-ed-src, .cg-src-more, .cg-lab input { min-height: 44px; }
  .cg-chip button { min-width: 44px; }
  .cg-merge select, .cg-merge .btn, .cg-guard .btn, .cg-src-r .btn, .cg-df .btn, .cg-shelf-add, .cg-linkbar .btn { min-height: 44px; }
  .cg-modes button { height: 44px; }
  .cg-ri { flex-wrap: wrap; }
  .cg-ri select { max-width: none; width: calc(100% - 26px); height: 44px; margin-left: 26px; }
  .cg-src-row { flex-wrap: wrap; }
  .cg-src-r { flex-direction: row; align-items: center; width: 100%; padding-left: 52px; justify-content: space-between; }
  .cg-linkbar { bottom: 40px; border-radius: 14px; }
  .cg-modal { align-items: end; padding: 0; }
  .cg-dlg { border-radius: 16px 16px 0 0; max-height: 92dvh; }
}
.cg-recs header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px 20px 12px; }
.cg-recs header [data-count]:empty { display: none; }

/* Smart graph-building: Review tab, confidence, bulk import */
.cg-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.cg-tabs::-webkit-scrollbar { display: none; }
.cg-tabs button { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.cg-n { font-style: normal; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #F2DDAE; color: #7a520c; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.cg-n:empty { display: none; }
.cg-rvs { padding: 4px 0 6px; border-top: 1px solid var(--line); }
.cg-rvs h4 { display: flex; align-items: center; gap: 8px; margin: 14px 20px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; }
.cg-rvs h4 em { font-style: normal; color: var(--ink-2); background: var(--surface-3); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.cg-rvc { margin: 0 16px 10px; padding: 12px 14px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; color: var(--ink-2); }
.cg-rvc.warn { background: #FFFCF5; box-shadow: inset 0 0 0 1px #F2DDAE; }
.cg-rvc > b { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13.5px; }
.cg-rvc p { margin: 6px 0 8px; line-height: 1.45; }
.cg-rvc .meta { font-size: 12.5px; }
.cg-conf { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; vertical-align: 1px; }
.cg-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cg-nm { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink); text-align: left; }
.cg-nm i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cg-opt { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 13px; color: var(--ink); cursor: pointer; }
.cg-opt input { margin-top: 2px; accent-color: var(--accent); }
.cg-rva { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cg-bulk { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.cg-bulk input { accent-color: var(--accent); }
.cg-bulk .cg-rt { flex: 1; }
.cg-bulk.off { cursor: default; }
.cg-bulk.off .cg-rt { opacity: .7; }
.cg-bulkbar { display: flex; align-items: center; gap: 6px; margin: 4px 20px 0; flex-wrap: wrap; }
.cg-bulkbar .meta { flex: 1; font-size: 12.5px; }
.cg-ri.dup { opacity: .78; }
.cg-dupnote { display: block; margin-top: 4px; font-size: 12px; color: #8a6012; }
@media (max-width: 760px) {
  .cg-nm { min-height: 44px; }
  .cg-rva .btn, .cg-bulk .btn, .cg-bulkbar .btn { min-height: 44px; }
  .cg-opt { min-height: 44px; align-items: center; }
  .cg-modes { overflow-x: auto; scrollbar-width: none; }
  .cg-modes button { flex: none; padding: 0 12px; }
}

/* ---------- Dark mode: status tints in the Brand Brain panel ---------- */
:root[data-theme="dark"] :is(.cg-b.bad, .cg-tg.bad[aria-pressed="true"], .cg-mic.on) { background: var(--red-50); color: var(--red-600); }
:root[data-theme="dark"] .cg-b.old { background: var(--amber-50); color: var(--amber-700); }
:root[data-theme="dark"] .cg-guard { background: var(--amber-50); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber-700) 35%, transparent); }
:root[data-theme="dark"] :is(.cg-ri.conflict, .cg-rvc.warn) { background: color-mix(in srgb, var(--amber-50) 60%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber-700) 35%, transparent); }
:root[data-theme="dark"] .cg-n { background: var(--amber-50); color: var(--amber-700); }
