.page:has(.brain) { max-width: 1400px; }
.brain { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.5rem; }
.brain-sidebar { border-right: 1px solid #2c2c3c; padding-right: 1rem; }
.brain-sidebar-head { color: #9a9aae; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 0.5rem; }
.brain-history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.brain-history button { width: 100%; text-align: left; background: none; color: #eaeaea; border: 1px solid transparent; border-radius: 8px; padding: 0.5rem; font-weight: normal; display: flex; flex-direction: column; gap: 0.2rem; }
.brain-history button:hover { background: #1c1c28; border-color: #2c2c3c; }
.brain-history small { color: #9a9aae; }
.brain-title h1 { margin: 0; }
.brain-stats { color: #9a9aae; font-size: 0.85rem; margin: 0.25rem 0 1rem; }
.brain-ask { background: #16161f; border: 1px solid #3a3a4e; border-radius: 12px; padding: 0.75rem; }
.brain-ask:focus-within { border-color: #e0a72d; }
.brain-ask textarea { width: 100%; box-sizing: border-box; background: transparent; border: none; color: #eaeaea; font: inherit; font-size: 1rem; resize: vertical; outline: none; }
.brain-ask-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.4rem; position: relative; }
.brain-hint { color: #9a9aae; font-size: 0.8rem; margin-right: auto; }
.brain-hint kbd { border: 1px solid #3a3a4e; border-radius: 4px; padding: 0 0.3rem; font-size: 0.75rem; }
.brain-picker { color: #9a9aae; font-size: 0.85rem; display: flex; gap: 0.4rem; align-items: center; }
.brain-stages { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0 0.5rem; font-size: 0.85rem; }
.brain-stages .stage { display: inline-flex; align-items: center; gap: 0.35rem; color: #9a9aae; }
.brain-stages .stage i { width: 9px; height: 9px; border-radius: 50%; background: #3a3a4e; }
.brain-stages .stage.ok { color: #eaeaea; } .brain-stages .stage.ok i { background: #3fb950; }
.brain-stages .stage.active i { background: #e0a72d; animation: brain-pulse 1s infinite; }
.brain-stages .stage.warn i { background: #e0a72d; } .brain-stages .stage.fail i { background: #d0453a; }
.brain-stages .stage-line { width: 2rem; height: 1px; background: #3a3a4e; }
.brain-stages code { color: #9a9aae; }
.brain-stages .stage-totals { margin-left: auto; color: #b8b8c8; }
@keyframes brain-pulse { 50% { opacity: 0.3; } }
/* The hidden attribute must win over the display:flex rules above it (equal-specificity [hidden] vs .class
   would otherwise lose to source order). */
.brain-stages[hidden], .brain-feedback[hidden] { display: none; }
.brain-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid #2c2c3c; margin: 0.5rem 0 1rem; }
.brain-tabs button { background: none; color: #b8b8c8; border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 0.55rem 0.9rem; font-weight: 600; }
.brain-tabs button.active { color: #eaeaea; border-bottom-color: #e0a72d; }
.brain-pill { display: inline-block; min-width: 1.2rem; padding: 0 0.4rem; border-radius: 999px; background: #22222f; color: #b8b8c8; font-size: 0.75rem; text-align: center; }
.brain-pill:empty { display: none; }
.brain-card { background: #16161f; border: 1px solid #2c2c3c; border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.brain-card-head { color: #9a9aae; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 0.6rem; display: flex; gap: 0.5rem; align-items: center; }
.brain-answer { line-height: 1.65; max-width: 75ch; }
.brain-answer .cite { display: inline-block; min-width: 1.1rem; padding: 0 0.3rem; margin: 0 0.1rem; border-radius: 4px; background: #10203a; color: #6cb8ff; font-size: 0.75rem; text-align: center; text-decoration: none; vertical-align: 1px; }
.brain-cited-head { color: #9a9aae; font-size: 0.85rem; margin: 1rem 0 0.5rem; border-top: 1px solid #2c2c3c; padding-top: 0.75rem; }
.brain-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem; }
.brain-cite-card { display: flex; gap: 0.6rem; align-items: center; background: #1c1c28; border: 1px solid #2c2c3c; border-radius: 8px; padding: 0.4rem; color: #eaeaea; text-decoration: none; }
.brain-cite-card:hover { border-color: #e0a72d; }
.brain-cite-card.uncited { opacity: 0.55; }
.brain-cite-card img, .brain-cite-card .poster-placeholder { width: 36px; height: 54px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.brain-cite-text { display: flex; flex-direction: column; font-size: 0.85rem; min-width: 0; }
.brain-feedback { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; color: #9a9aae; font-size: 0.85rem; margin-top: 1rem; }
.brain-feedback button { background: #1c1c28; color: #eaeaea; border: 1px solid #3a3a4e; font-weight: normal; padding: 0.3rem 0.7rem; }
.brain-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.brain-chips .chip { border: 1px solid #2c2c3c; border-radius: 999px; padding: 0.2rem 0.65rem; font-size: 0.8rem; color: #9a9aae; }
.brain-chips .chip b { color: #eaeaea; }
.brain-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.brain-table th { text-align: left; color: #9a9aae; font-weight: normal; font-size: 0.75rem; text-transform: uppercase; padding: 0.4rem; }
.brain-table td { padding: 0.5rem 0.4rem; border-top: 1px solid #22222f; }
.brain-table tr.unsent td { opacity: 0.5; }
.brain-table tr.cutline td { border-top: 1px dashed #d0453a; padding: 0; text-align: right; }
.brain-table tr.cutline span { color: #d0453a; font-size: 0.75rem; border: 1px solid #d0453a; border-radius: 999px; padding: 0 0.5rem; position: relative; top: -0.6rem; background: #16161f; }
.rank { display: inline-block; min-width: 1.4rem; text-align: center; border-radius: 4px; font-size: 0.75rem; padding: 0.1rem 0.3rem; }
.rank.mine { background: #2a1f40; color: #b39dff; } .rank.about { background: #10203a; color: #6cb8ff; } .rank.kw { background: #13301c; color: #56d364; }
.bar { display: inline-block; width: 120px; height: 8px; background: #22222f; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar.wide { display: block; width: 100%; margin-top: 0.5rem; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #8a5cf6, #e0a72d); }
.brain-pre { white-space: pre-wrap; font-size: 0.8rem; color: #cfcfdc; max-height: 420px; overflow: auto; margin: 0; }
.role { border-radius: 4px; padding: 0.1rem 0.45rem; font-size: 0.75rem; text-transform: none; }
.role.system { background: #3a2410; color: #f0a35c; } .role.user { background: #10203a; color: #6cb8ff; }
.copy { margin-left: auto; background: #1c1c28; color: #eaeaea; border: 1px solid #3a3a4e; font-weight: normal; padding: 0.15rem 0.6rem; font-size: 0.8rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpis div { background: #16161f; border: 1px solid #2c2c3c; border-radius: 12px; padding: 1rem; display: flex; flex-direction: column; }
.kpis b { font-size: 1.6rem; } .kpis span { color: #9a9aae; font-size: 0.75rem; text-transform: uppercase; }
.wf-row { display: grid; grid-template-columns: 130px 1fr 80px; gap: 0.75rem; align-items: center; font-size: 0.85rem; padding: 0.3rem 0; }
.wf-track { position: relative; height: 10px; background: #1c1c28; border-radius: 5px; }
.wf-track i { position: absolute; top: 0; height: 100%; border-radius: 5px; }
.wf-track i.plan { background: #e0a72d; } .wf-track i.embed { background: #b39dff; } .wf-track i.search { background: #6cb8ff; } .wf-track i.generate { background: #f0883e; }
.graph-toolbar { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.75rem; position: relative; }
.graph-toolbar input { flex: 1; box-sizing: border-box; background: #16161f; border: 1px solid #2c2c3c; border-radius: 8px; padding: 0.5rem 0.75rem; color: #eaeaea; font: inherit; outline: none; }
.graph-toolbar input:focus { border-color: #e0a72d; }
.graph-toolbar button { background: #1c1c28; color: #eaeaea; border: 1px solid #3a3a4e; font-weight: normal; padding: 0.5rem 0.9rem; }
.graph-suggestions { position: absolute; top: 100%; left: 0; right: 6.5rem; margin-top: 0.25rem; background: #16161f; border: 1px solid #2c2c3c; border-radius: 8px; max-height: 260px; overflow: auto; z-index: 5; }
.graph-suggestions button { display: block; width: 100%; text-align: left; background: none; color: #eaeaea; border: none; border-radius: 0; padding: 0.5rem 0.75rem; font-weight: normal; }
.graph-suggestions button:hover { background: #1c1c28; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.5rem; font-size: 0.8rem; color: #9a9aae; }
.graph-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.graph-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.graph-notice { font-size: 0.8rem; color: #e0a72d; margin-bottom: 0.5rem; }
#graph-svg { display: block; width: 100%; height: 70vh; min-height: 420px; background: #16161f; border: 1px solid #2c2c3c; border-radius: 12px; }
.brain-mic, .brain-help { background: #1c1c28; color: #eaeaea; border: 1px solid #3a3a4e; border-radius: 999px; width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-weight: normal; line-height: 1; }
.brain-mic:disabled, .brain-help:disabled { opacity: 0.4; }
.brain-mic.recording { background: #d0453a; border-color: #d0453a; animation: brain-pulse 1s infinite; }
.brain-mic.transcribing { opacity: 0.6; }
.brain-mic-time { color: #9a9aae; font-size: 0.8rem; }
.brain-voice-popover { position: absolute; top: 100%; right: 0; margin-top: 0.5rem; z-index: 6; width: 300px; background: #16161f; border: 1px solid #2c2c3c; border-radius: 12px; padding: 1rem; font-size: 0.85rem; color: #cfcfdc; }
.brain-voice-popover p { margin: 0.4rem 0; }
.brain-voice-popover ul { margin: 0.4rem 0; padding-left: 1.2rem; }
.brain-voice-section { color: #9a9aae; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 0.75rem !important; }
@media (max-width: 800px) {
    .brain { grid-template-columns: 1fr; }
    .brain-sidebar { border-right: none; border-bottom: 1px solid #2c2c3c; padding: 0 0 0.75rem; max-height: 9rem; overflow: auto; }
    .brain-stages .stage-totals { margin-left: 0; width: 100%; }
    .brain-ask-bar { flex-direction: column; align-items: stretch; }
    .brain-hint { margin-right: 0; }
    .brain-picker { justify-content: space-between; }
    .brain-picker select, #brain-ask-button { width: 100%; box-sizing: border-box; }
}
