/* Nexus Board v0.0.1: compact board layout (from Eric's v0.2 prototype), AI Connect tokens. */
:root {
  --navy: #2c397c; --navy-2: #3b4da8; --navy-soft: #eef0fa;
  --ink: #101827; --text: #474f60; --muted: #5b657b; --faint: #9aa1ae;
  --line: #e6e8ee; --line-2: #cdd2de; --soft: #f5f6fa; --bg: #fff;
  --green: #0b6e0b; --green-bg: #e7f6ec; --amber: #8a5a0b; --amber-bg: #fef3c7; --red: #931414; --red-bg: #fdecec;
  --cyan: #1fb6d9; --cyan-bg: #e3f7fc; --purple: #6d32a4;
  --radius: 16px; --shadow: 0 2px 8px rgba(16, 24, 39, 0.08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 39, 0.16), 0 2px 6px rgba(16, 24, 39, 0.06);
  --sans: Roboto, -apple-system, "Segoe UI", system-ui, sans-serif;
  --display: Raleway, "Helvetica Neue", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
svg { flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--navy-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* header: compact and fixed */
.appbar { position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, 0.96); backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.appbar::before { content: ""; display: block; height: 3px; background: linear-gradient(90deg, #02d7ee, var(--navy-2) 55%, #8c49c9); }
.bar { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 10px; }
.bar-main { height: 54px; }
.bar-tools { min-height: 44px; padding-bottom: 8px; flex-wrap: wrap; row-gap: 6px; }
.brand { display: flex; align-items: center; gap: 8px; font: 800 18px/1 var(--display); color: var(--ink); white-space: nowrap; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #02d7ee, var(--navy-2) 55%, #8c49c9); color: #fff; display: grid; place-items: center; font-size: 14px; }
.divider { width: 1px; height: 22px; background: var(--line); flex: none; }
.switcher { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 340px; height: 36px; padding: 0 8px 0 10px; border: 1px solid transparent; border-radius: 10px; background: none; cursor: pointer; font-weight: 500; color: var(--ink); }
.switcher:hover, .switcher[aria-expanded="true"] { background: var(--soft); border-color: var(--line); }
.switcher .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher .chev { color: var(--muted); }
.stats { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.conn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--soft); color: var(--muted); white-space: nowrap; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn[data-state="live"] { background: var(--green-bg); color: var(--green); }
.conn[data-state="live"] .dot { animation: pulse 2.2s infinite; }
.conn[data-state="waiting"] { background: var(--navy-soft); color: var(--navy); }
.conn[data-state="reconnecting"] { background: var(--amber-bg); color: var(--amber); }
.conn[data-state="ended"] { background: var(--red-bg); color: var(--red); }
.conn[data-state="closed"] { background: var(--soft); color: var(--muted); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(11, 110, 11, 0.45); } 70% { box-shadow: 0 0 0 6px rgba(11, 110, 11, 0); } 100% { box-shadow: 0 0 0 0 rgba(11, 110, 11, 0); } }
.iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.iconbtn:hover { background: var(--soft); }
.iconbtn[aria-expanded="true"] { background: var(--soft); border-color: var(--line-2); }
.btn-primary, .iconbtn.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover, .iconbtn.btn-primary:hover { background: var(--navy-2); }
.iconbtn.emphasis { background: var(--navy-soft); border-color: var(--navy-2); color: var(--navy); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--purple); color: #fff; font-size: 11px; font-weight: 700; line-height: 15px; text-align: center; border: 2px solid #fff; }
.badge.warn { background: var(--amber); }

/* agents: presence dots, click to filter */
.agents { display: flex; align-items: center; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.agents::-webkit-scrollbar { display: none; }
.lbl-small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip { --agent: var(--navy); display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px 0 9px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: 500 12.5px var(--mono); color: var(--agent); cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--line-2); background: var(--soft); }
.chip .dot { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--agent); }
.chip.active .dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--agent); opacity: 0.35; }
.chip.away { border-style: dashed; }
.chip.away .dot { background: #fff; box-shadow: inset 0 0 0 2px var(--agent); }
.chip .n { color: var(--muted); font-family: var(--sans); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--agent); border-color: var(--agent); color: #fff; }
.chip[aria-pressed="true"] .n { color: #fff; }
.chip[aria-pressed="true"] .dot { background: #fff; }
.chip.new { animation: chip-in 700ms var(--ease); }
@keyframes chip-in { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.linkbtn { border: 0; background: none; padding: 4px 6px; border-radius: 6px; color: var(--navy-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.linkbtn:hover { text-decoration: underline; }

/* sort */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--soft); border: 1px solid var(--line); }
.seg button { border: 0; background: none; height: 28px; padding: 0 11px; border-radius: 7px; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(16, 24, 39, 0.14); }
.sort-select { display: none; height: 32px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px; background: #fff; font-size: 13px; color: var(--ink); }
.hintbar { max-width: 1240px; margin: 0 auto; padding: 0 24px 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.hintbar kbd { font: 500 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: #fff; color: var(--ink); }

.banner { max-width: 1240px; margin: 0 auto 8px; padding: 8px 24px; font-size: 13.5px; color: var(--amber); background: var(--amber-bg); border-radius: 10px; }
.banner.bad { color: var(--red); background: var(--red-bg); }

/* cards */
main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 120px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.card { --agent: var(--navy); position: relative; display: flex; flex-direction: column; transition: opacity 0.15s ease, transform 0.15s ease; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--agent); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 20px 12px; scroll-margin-top: 140px; }
.card.leading { background: linear-gradient(180deg, #f0f9f3 0, #fff 72px); }
.card:focus { outline: none; }
.card:focus-visible { outline: 2px solid var(--navy-2); outline-offset: 3px; }
.card-top { display: flex; align-items: center; gap: 8px; font: 12px/1 var(--mono); color: var(--muted); min-height: 24px; }
.card-top .author { margin-left: auto; color: var(--agent); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grip { display: inline-flex; opacity: 0.45; align-items: center; justify-content: center; width: 26px; height: 24px; margin-left: -4px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: grab; touch-action: none; }
.manual .grip, .card:hover .grip, .grip:focus-visible { opacity: 1; }
.invite-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; justify-content: center; order: 99999; padding: 16px 20px; border: 1.5px dashed var(--navy-2); border-radius: var(--radius); background: var(--navy-soft); }
.invite-tile .it-title { margin: 0; font-weight: 700; color: var(--navy); }
.invite-tile .it-text { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.grip:hover { background: var(--soft); border-color: var(--line); }
.grip[aria-pressed="true"] { background: var(--navy); color: #fff; }
.card-title { margin: 6px 0; font: 700 17px/1.3 var(--display); color: var(--ink); letter-spacing: -0.005em; overflow-wrap: anywhere; }
.card-body { margin: 0 0 12px; font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.card-meta { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.score { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 8px; border-radius: 7px; font: 700 12.5px var(--mono); background: var(--soft); color: var(--ink); }
.score.pos { background: var(--green-bg); color: var(--green); }
.score.neg { background: var(--red-bg); color: var(--red); }
.votes { font: 12.5px var(--mono); color: var(--muted); }
.cmt-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; cursor: pointer; }
.cmt-btn:hover { border-color: var(--line-2); color: var(--ink); }
.cmt-btn.has { color: var(--navy); font-weight: 500; }
.cmt-btn[aria-expanded="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font: 12px var(--mono); color: var(--muted); }
.new-badge { font: 700 10.5px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 999px; background: var(--cyan-bg); color: #0b5e73; }
.card.flash { animation: flash 1.8s; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--cyan), var(--shadow); } 100% { box-shadow: var(--shadow); } }
.card.dragging, .card.grabbed { box-shadow: var(--shadow-lg); outline: 2px dashed var(--navy-2); outline-offset: 3px; }
.card.dragging { opacity: 0.55; transform: scale(0.98); }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card.dragging { transform: none; } }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }

/* states: waiting for the first agent, filter empty, ended */
.state { max-width: 620px; margin: 32px auto; text-align: center; }
.state-icon { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; display: grid; place-items: center; background: var(--navy-soft); color: var(--navy); }
.state-icon.muted { background: var(--soft); color: var(--muted); }
.state h2 { margin: 0 0 8px; font: 700 22px/1.3 var(--display); color: var(--ink); }
.state p { margin: 0 auto 16px; max-width: 540px; }
.state .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.invite-row { display: flex; gap: 8px; margin: 0 auto 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); padding: 8px; }
.invite-row input { flex: 1; min-width: 0; border: 0; background: transparent; font: 12.5px/1.5 var(--mono); color: var(--ink); padding: 6px 8px; }
.invite-row input:focus { outline: none; }
.qr { margin: 8px auto 16px; width: fit-content; }
.qr svg { display: block; width: 150px; height: 150px; }
.steps { list-style: none; counter-reset: s; margin: 0 auto 12px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: left; }
.steps li { counter-increment: s; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 13.5px; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; font: 700 12px var(--sans); margin-bottom: 6px; }
.hint { font-size: 13.5px; color: var(--muted); }
.foot { margin-top: 48px; font-size: 13px; color: var(--muted); }
.foot p { margin: 4px 0; }

/* popovers */
.pop { position: fixed; z-index: 60; width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; max-height: calc(100vh - 120px); overflow: auto; }
#pop-boards { width: 380px; }
#pop-bell { width: 380px; }
.pop h3 { margin: 8px 10px 6px; font: 600 11.5px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.pop h3 .attention { margin-left: 6px; text-transform: none; letter-spacing: 0; color: var(--amber); font-weight: 500; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 7px 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer; font-size: 14px; color: var(--ink); }
.mi:hover, .mi:focus-visible { background: var(--soft); outline: none; }
.mi:focus-visible { box-shadow: inset 0 0 0 2px var(--navy-2); }
.mi .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.mi .grow { flex: 1; min-width: 0; }
.mi[aria-current="true"] { background: var(--navy-soft); }
.mi-row { display: flex; align-items: center; gap: 2px; }
.mi-row .mi { flex: 1; min-width: 0; }
.mi-rm { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.mi-rm:hover, .mi-rm:focus-visible { background: var(--soft); color: var(--ink); }
.mi.danger { color: var(--red); }
.mi.danger .sub { color: var(--muted); }
.about { margin: 4px 6px 8px; padding: 12px; border-radius: 10px; background: var(--soft); font-size: 13px; }
.about strong { display: block; font: 700 15px var(--display); color: var(--ink); margin-bottom: 4px; }
.tag { display: inline-block; font: 600 10.5px var(--sans); text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.exp { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.pop .note { margin: 4px 10px 8px; font-size: 12px; color: var(--muted); }
.pop-empty { padding: 14px 12px; text-align: center; color: var(--muted); font-size: 13.5px; margin: 0; }
.activity { list-style: none; margin: 0; padding: 0 4px 4px; display: flex; flex-direction: column; gap: 4px; }
.msg { font-size: 13px; padding: 6px 8px; border-radius: 8px; overflow-wrap: anywhere; }
.msg .at { display: block; font: 11.5px var(--mono); color: var(--muted); }
.msg.event { color: var(--text); }
.msg.refused { background: var(--amber-bg); color: #6b4608; }
.msg.refused .at { color: #6b4608; }
.msg.refused.resolved { background: var(--soft); color: var(--text); }
.msg.unanswered { background: var(--red-bg); color: var(--red); }
.msg.unread { box-shadow: inset 3px 0 0 var(--purple); }

/* comments in a layer over the board */
.cmt { position: absolute; z-index: 50; width: 380px; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); }
.cmt-head { display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px 10px 16px; border-bottom: 1px solid var(--line); position: relative; }
.cmt-kicker { font: 12px var(--mono); color: var(--muted); }
.cmt-head h2 { margin: 2px 0 0; font: 700 15px/1.3 var(--display); color: var(--ink); overflow-wrap: anywhere; }
.cmt-head .iconbtn { margin-left: auto; border-color: transparent; }
.cmt-list { list-style: none; margin: 0; padding: 6px 0; overflow: auto; flex: 1; min-height: 60px; overscroll-behavior: contain; }
.cmt-list li { display: flex; gap: 10px; padding: 10px 16px; }
.cmt-list li + li { border-top: 1px solid #f0f1f5; }
.cmt-list li.fresh { animation: fresh 2.4s; }
@keyframes fresh { 0%, 50% { background: var(--cyan-bg); } 100% { background: transparent; } }
.av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 11px var(--sans); color: #fff; flex: none; }
.cm-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.cm-meta b { font: 500 12.5px var(--mono); color: var(--ink); }
.cm-meta .ord { margin-left: auto; font-family: var(--mono); }
.cm-text { margin: 2px 0 0; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.cmt-empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.cmt-jump { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow); cursor: pointer; white-space: nowrap; }
.cmt-foot { padding: 9px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--soft); border-radius: 0 0 16px 16px; }
.backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(16, 24, 39, 0.35); }
.cmt.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto !important; width: auto !important; max-height: 78vh !important; border-radius: 18px 18px 0 0; }
.cmt.sheet .cmt-foot { border-radius: 0; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 100%; padding: 8px 8px 8px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; box-shadow: var(--shadow-lg); animation: tin 0.2s ease-out; }
.toast[data-kind="new"] { background: var(--navy); }
.toast[data-kind="error"] { background: #7f1d1d; }
.toast .msg-t { flex: 1; min-width: 0; }
.toast .t-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--agent, #fff); box-shadow: 0 0 0 2px #fff; flex: none; }
.toast .t-act { height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: #fff; color: var(--ink); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; }
.toast .t-x { width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: #fff; cursor: pointer; display: grid; place-items: center; }
.toast .t-x:hover { background: rgba(255, 255, 255, 0.12); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* QR dialog */
.lightbox { border: 0; padding: 0; background: transparent; }
.lightbox::backdrop { background: rgba(16, 24, 39, 0.55); }
.lightbox-card { background: #fff; border-radius: 16px; padding: 20px 24px; text-align: center; box-shadow: var(--shadow-lg); }
.lightbox-card h2 { margin: 0 0 8px; font: 700 18px var(--display); color: var(--ink); }
.lightbox-card .qr svg { width: 220px; height: 220px; }

/* a light touch of confetti, once per board, on the first agent */
.confetti { position: fixed; top: 0; left: 0; width: 8px; height: 12px; border-radius: 2px; z-index: 80; pointer-events: none; animation: fall 1.4s var(--ease) forwards; }
@keyframes fall { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

@media (max-width: 760px) {
  .bar { padding: 0 16px; gap: 8px; }
  .hintbar { padding: 0 16px 8px; }
  main { padding: 14px 16px 120px; }
  .brand .word, .divider, .bar-main .stats, .lbl, .conn .txt { display: none; }
  .conn { padding: 0; width: 28px; justify-content: center; }
  .appbar .iconbtn { padding: 0; width: 36px; }
  .switcher { flex: 1; max-width: none; }
  .seg { display: none; }
  .sort-select { display: inline-block; }
  .bar-tools { flex-wrap: nowrap; }
  .bar-tools .lbl-small { display: none; }
  .agents { flex: 1; }
  .steps { grid-template-columns: 1fr; }
  .pop { left: 8px !important; right: 8px; width: auto !important; }
  .toasts { bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } .confetti { display: none; } }
