/* Shared context. Agreed decisions sit on solid surfaces with a sage rule;
   proposed and contested material is dashed and amber, so the two never read
   as the same kind of fact. */
.context-summary { margin:-12px 0 22px; font-size:13px; color:var(--muted); overflow-wrap:anywhere; }
.context-layout { display:grid; grid-template-columns:minmax(0,1fr) 320px; gap:28px; align-items:start; }
.context-main { display:grid; gap:28px; min-width:0; }
.context-side { display:grid; gap:16px; position:sticky; top:16px; min-width:0; }
.context-main h2 { margin-bottom:12px; font-size:15px; font-weight:600; }
.context-list { display:grid; gap:14px; }
.context-empty { max-width:64ch; padding:18px 0; color:var(--muted); font-size:14px; line-height:1.6; }

.context-item { display:grid; gap:10px; min-width:0; padding:16px 18px; border-radius:var(--radius-panel); background:var(--surface); border:1px solid var(--line); }
.context-item:focus-visible { outline:2px solid var(--focus); outline-offset:3px; }
.context-decision { border-left:3px solid var(--done); }
.context-proposal,.context-challenge { border:1px dashed var(--line-strong); background:var(--surface-subtle); }
.context-attention.decide .context-proposal,.context-attention.decide .context-challenge { border-color:color-mix(in srgb,var(--human) 55%,transparent); }
.context-attention>h2 { color:var(--muted); }
.context-attention.decide>h2 { color:var(--human); }
.context-item-head { display:flex; align-items:center; flex-wrap:wrap; gap:6px 12px; min-width:0; }
.context-item-head .button { min-height:30px; font-size:12.5px; margin-left:auto; }
.context-item-title { font-size:16px; font-weight:600; overflow-wrap:anywhere; }
.context-decision-title { font-family:var(--font-display); font-size:clamp(20px,1.9vw,24px); line-height:1.2; font-weight:640; letter-spacing:-.015em; overflow-wrap:anywhere; }
.context-meta { font-size:12.5px; color:var(--faint); overflow-wrap:anywhere; }
.context-author { display:inline-flex; align-items:center; gap:8px; min-width:0; font-size:13px; overflow-wrap:anywhere; }
.context-agent-label { padding:1px 8px; border-radius:999px; font-size:12px; font-weight:550; color:var(--agent); background:var(--agent-soft); }
.badge.context-accepted { background:var(--done-soft); color:var(--done); }
.badge.context-proposed { background:var(--human-soft); color:var(--human); }
.badge.context-proposed::before { background:transparent; border:1.5px dashed currentColor; }
.badge.context-challenged { background:var(--warning-bg); color:var(--warning); }
.context-statement,.context-rationale { max-width:72ch; font-size:14.5px; line-height:1.6; white-space:pre-wrap; overflow-wrap:anywhere; }
.context-rationale { font-size:13.5px; color:var(--muted); }
.context-contested { font-size:13px; color:var(--warning); }
.context-title-link { padding:0; border:0; background:none; color:inherit; font:inherit; text-align:left; text-decoration:underline; text-decoration-color:var(--line-strong); text-underline-offset:3px; cursor:pointer; overflow-wrap:anywhere; }
.context-title-link:hover { text-decoration-color:currentColor; }

.context-blocks { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px 28px; margin-top:4px; }
.context-block { display:grid; gap:6px; align-content:start; min-width:0; }
.context-block h4,.context-label { font-size:12.5px; font-weight:550; color:var(--muted); }
.context-block ul { list-style:none; margin:0; padding:0; display:grid; gap:7px; }
.context-block li { position:relative; padding-left:16px; font-size:13.5px; line-height:1.5; overflow-wrap:anywhere; }
.context-block li::before { content:""; position:absolute; left:0; top:.72em; width:8px; border-top:2px solid var(--line-strong); }
.context-alternatives li { display:grid; gap:2px; }
.context-alternatives span:not(.context-meta) { color:var(--muted); }
.context-refs { display:flex; flex-wrap:wrap; gap:6px; }
.context-ref { display:inline-flex; align-items:center; max-width:100%; min-height:28px; padding:3px 10px; border:1px solid var(--line); border-radius:999px; background:var(--surface-subtle); color:var(--ink); font-size:12.5px; line-height:1.3; text-align:left; overflow-wrap:anywhere; }
button.context-ref { cursor:pointer; }
button.context-ref:hover { border-color:var(--line-strong); background:var(--surface-hover); }
span.context-ref { color:var(--muted); border-style:dashed; }

.context-diff { display:grid; gap:10px; padding:12px 14px; border-radius:var(--radius-control); background:var(--surface); min-width:0; }
.context-diff h4 { font-size:12.5px; font-weight:550; color:var(--muted); }
.context-change { display:grid; gap:4px; min-width:0; }
.context-change ul { list-style:none; margin:0; padding:0; display:grid; gap:3px; }
.context-change :is(p,li) { position:relative; padding:2px 0 2px 20px; font-size:13.5px; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
.context-change :is(p,li)::before { position:absolute; left:4px; font-family:var(--font-mono); font-weight:600; }
.context-added::before { content:"+"; color:var(--done); }
.context-removed { color:var(--muted); text-decoration:line-through; text-decoration-color:color-mix(in srgb,var(--danger) 60%,transparent); }
.context-removed::before { content:"−"; color:var(--danger); }

.context-actions { display:flex; flex-wrap:wrap; gap:8px; }
.context-item label,.context-item .message { margin:0; }
.context-item textarea,.context-editor textarea { min-height:0; margin-top:6px; }
.context-item select { display:block; margin-top:6px; }
.context-decision-body { display:grid; gap:10px; }
.context-challenge-form { display:grid; gap:10px; padding-top:12px; border-top:1px solid var(--line); }
.context-challenge-form .message { margin:0; }
.context-help { display:block; font-weight:400; }

.context-editor { display:grid; gap:14px; padding:20px; border:1px dashed color-mix(in srgb,var(--human) 55%,transparent); border-radius:var(--radius-panel); background:var(--surface); }
.context-editor h2 { margin:0; font-family:var(--font-display); font-size:19px; font-weight:640; }
.context-editor>.help { margin-top:-6px; }
.context-editor>label,.context-editor fieldset,.context-editor .message { margin:0; }
.context-editor :is(textarea,input,select) { font-weight:400; }
.context-editor-refs { display:grid; gap:14px; }
.context-rows ol { list-style:none; margin:0 0 6px; padding:0; display:grid; gap:6px; }
.context-rows li { display:flex; gap:6px; align-items:center; min-width:0; }
.context-rows li>input { flex:1; min-width:0; }
.context-rows .quiet { flex-shrink:0; }
.context-alternative-row { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1.4fr) minmax(0,.6fr); gap:6px; flex:1; min-width:0; }
.context-ref-row { display:flex; gap:6px; flex:1; min-width:0; }
.context-ref-row select { flex:0 0 11.5em; min-width:0; }
.context-ref-row input { flex:1; }
.context-ref-row .context-version { flex:0 0 84px; }
.context-ref-row input,.context-ref-row select,.context-alternative-row input { min-width:0; margin:0; }
.context-editor .message.warning { display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px; }

.context-card { display:grid; gap:8px; padding:16px; border:1px solid var(--line); border-radius:var(--radius-panel); background:var(--surface); min-width:0; }
.context-card h2 { font-size:13px; font-weight:560; color:var(--muted); }
.context-card .button { justify-self:start; margin-top:4px; }
.context-brief-purpose { font-family:var(--font-display); font-size:18px; line-height:1.3; font-weight:620; letter-spacing:-.01em; overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; overflow:hidden; }
.context-arch-summary { font-size:13.5px; line-height:1.5; overflow-wrap:anywhere; }
.context-pending { font-size:13px; color:var(--human); }

@media (max-width:1100px) {
  .context-layout { grid-template-columns:1fr; }
  .context-side { position:static; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); }
}
@media (max-width:700px) {
  .context-blocks { grid-template-columns:1fr; }
  .context-item { padding:14px 12px; }
  .context-editor { padding:16px 14px; }
  .context-item-head .button { margin-left:0; }
  .context-alternative-row { grid-template-columns:1fr; }
  .context-ref-row { flex-wrap:wrap; }
  .context-ref-row select { flex-basis:100%; }
  .context-rows li { align-items:flex-start; }
}

/* "Context changed": open items read as attention (amber rule); resolved ones
   fold away. Each affected record lists the links that put it there. */
.context-changed { display:grid; gap:12px; min-width:0; }
.context-changed>h2 { color:var(--human); }
.context-changed-item { border-left:3px solid var(--human); }
.context-changed-item.resolved { border-left-color:var(--line-strong); }
.context-changed-targets { list-style:none; margin:0; padding:0; display:grid; gap:10px; }
.context-changed-target { display:grid; gap:6px; min-width:0; padding:10px 12px; border-radius:var(--radius-control); background:var(--surface-subtle); }
.context-block .context-changed-target { padding-left:12px; }
.context-block .context-changed-target::before { content:none; }
.context-changed-target-head { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; min-width:0; font-size:13.5px; }
.context-changed-links { list-style:none; margin:0; padding:0; display:grid; gap:2px; }
.context-block .context-changed-links li { padding-left:14px; font-size:12.5px; color:var(--muted); }
.context-changed-target .context-actions { align-items:center; }
.context-changed-target .context-actions input { flex:1 1 220px; min-width:0; }
.context-changed-composer { display:grid; gap:8px; min-width:0; }
.context-changed-composer textarea { width:100%; min-width:0; font-size:13.5px; line-height:1.5; }
.context-changed-notify { display:grid; gap:8px; margin:0; padding:10px 12px; border:1px solid var(--line); border-radius:var(--radius-control); min-width:0; }
.context-changed-notify legend { padding:0 4px; font-size:12.5px; font-weight:550; color:var(--muted); }
.context-changed-person { display:inline-flex; align-items:center; gap:4px; font-size:13px; }
.context-changed-item>.context-actions input,.context-changed-notify>input { flex:1 1 220px; min-width:0; }
.context-changed-history summary,.context-changed-resolved summary { cursor:pointer; font-size:12.5px; color:var(--muted); }
.context-changed-history ul { margin:6px 0 0; padding-left:18px; display:grid; gap:4px; font-size:12.5px; color:var(--muted); overflow-wrap:anywhere; }
.context-changed-resolved>.context-list { margin-top:10px; }
