* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, sans-serif; }
body { display: flex; flex-direction: column; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #eee; background: #fafafa; height: 52px; flex: 0 0 52px; }
#search { flex: 1; height: 32px; padding: 0 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.toggle { padding: 4px 10px; font-size: 11px; color: #666; background: #fff; border: 1px dashed #aaa; border-radius: 3px; cursor: pointer; }
.toggle.active { background: #1976d2; color: #fff; border-style: solid; }
.role-filters { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #888; }
.chip { padding: 3px 8px; background: #fff; border: 1px solid #ddd; border-radius: 10px; cursor: pointer; font-size: 10px; color: #888; }
.chip.active { background: #e3f2fd; color: #1976d2; border-color: #90caf9; }

main { flex: 1; display: grid; grid-template-columns: 1fr 280px; overflow: hidden; }
#graph-area { position: relative; background: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px), #f7f9fc; background-size: 24px 24px; overflow: hidden; }
#graph { display: block; width: 100%; height: 100%; }

#detail-panel { padding: 14px; border-left: 1px solid #eee; background: #fafafa; font-size: 12px; line-height: 1.6; overflow-y: auto; }
#detail-panel h2 { font-size: 14px; margin: 0 0 6px; }
#detail-panel .label { font-size: 10px; color: #888; margin: 12px 0 4px; letter-spacing: 0.5px; }
.role-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { font-size: 10px; padding: 2px 8px; background: #e3f2fd; border-radius: 10px; }
#p-source { color: #1976d2; font-size: 11px; word-break: break-all; }
#detail-panel button { display: block; width: 100%; padding: 6px; margin-top: 6px; font-size: 11px; background: #fff; border: 1px solid #ddd; border-radius: 3px; cursor: pointer; text-align: left; }
.lens-group { display: flex; gap: 4px; margin-top: 6px; }
.lens-group select { flex: 1; font-size: 11px; padding: 4px; }

.node { cursor: pointer; }
.node circle { fill: #e3f2fd; stroke: #1976d2; stroke-width: 1.5; transition: stroke-width 0.15s ease; }
.node:hover circle { stroke-width: 3; }
.node text { pointer-events: none; font-size: 10px; font-weight: 500; user-select: none; }
.node.center circle { fill: #ffd24a; stroke: #b87700; stroke-width: 2.5; }
.node.center text { font-weight: 700; }
.node.idea circle      { fill: #c8e6c9; stroke: #43a047; }
.node.idea text        { fill: #1b5e20; }
.node.center.idea circle { fill: #fff59d; stroke: #43a047; stroke-width: 2.5; }
.node.query-transient circle { fill: #eee; stroke: #888; stroke-dasharray: 4 2; }
.node.dim { opacity: 0.25; }
.node.extended circle { fill: #f0f0f0; stroke: #b0b0b0; stroke-width: 1; }
.node.extended text { fill: #888; font-weight: 400; }
.node.extended { opacity: 0.55; }
.node.extended:hover { opacity: 0.95; }
/* idea wins over extended — keep source distinction even in dimmer outer ring. */
.node.idea.extended circle { fill: #c8e6c9; stroke: #43a047; }
.node.idea.extended text { fill: #1b5e20; }
.node.level-broader circle { fill: #c8e6c9; stroke: #388e3c; }
.node.level-sibling circle { fill: #bbdefb; stroke: #1976d2; }
.node.level-narrower circle { fill: #ffcdd2; stroke: #d32f2f; }
.link { stroke: #c8d0db; stroke-width: 1.5; }
.link.dim { stroke-opacity: 0.15; }
.link.extended { stroke: #d8d8d8; stroke-opacity: 0.55; }
.link.pair { stroke: #b8c5d0; stroke-opacity: 0.5; stroke-dasharray: 3 3; stroke-width: 1; }

.tooltip { position: absolute; background: #263238; color: #fff; padding: 6px 9px; border-radius: 4px; font-size: 11px; pointer-events: none; white-space: pre-line; opacity: 0; transition: opacity 0.15s; max-width: 240px; }
.tooltip.visible { opacity: 0.95; }

.insight-card { margin-top: 8px; padding: 8px; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; }
.insight-card strong { display: block; margin-bottom: 2px; font-size: 12px; }
.insight-card span { font-size: 11px; color: #555; }

#quick-add { margin-top: 14px; padding: 10px; background: #fff; border: 1px dashed #bbb; border-radius: 4px; }
#quick-add .label { margin-top: 0; }
#quick-add input[type=text], #quick-add textarea { width: 100%; padding: 5px 7px; margin-top: 5px; font-size: 11px; border: 1px solid #ddd; border-radius: 3px; font-family: inherit; }
#quick-add textarea { resize: vertical; }
#quick-add .qa-roles { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; }
#quick-add .qa-roles label { font-size: 10px; color: #555; display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
#quick-add .qa-roles input { margin: 0; }
#quick-add .qa-submit { margin-top: 8px; background: #1976d2; color: #fff; border-color: #1976d2; text-align: center; font-weight: 600; }
#quick-add .qa-submit:disabled { opacity: 0.5; cursor: default; }
#quick-add .qa-warn { margin: 6px 0; padding: 6px 8px; font-size: 10px; color: #b26a00; background: #fff8e1; border: 1px solid #ffe082; border-radius: 3px; line-height: 1.4; }
#quick-add .qa-status { margin-top: 6px; font-size: 11px; min-height: 14px; }
#quick-add .qa-status.ok { color: #2e7d32; }
#quick-add .qa-status.err { color: #c62828; }

#auth-gate:not([hidden]) { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #f7f9fc; z-index: 1000; }
#auth-gate .auth-card { background: #fff; padding: 32px 40px; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); max-width: 420px; text-align: center; }
#auth-gate h2 { margin: 0 0 12px; font-size: 18px; }
#auth-gate p { margin: 8px 0; font-size: 13px; color: #444; line-height: 1.5; }
#auth-gate code { background: #eef2f7; padding: 2px 6px; border-radius: 3px; font-family: SFMono-Regular, Menlo, monospace; font-size: 12px; color: #1976d2; }
#auth-gate .muted { color: #888; font-size: 11px; margin-top: 16px; }
