/* Bleed plugins (6 Oct): Settings → Plugins, the ChatGPT connection card (bleed-plugins.js).
   It sits inside the settings sheet's own .jp-set and reuses its .jp-row / .jp-switch /
   .jp-select / .jp-set-action (jbot.css); this file adds only the card. Every colour is a
   token from app.css §0, so light and dark are the same rules. A state is a mark and a
   label together, never colour alone. No motion beyond the sheet's own. */

.bp { display: grid; gap: 10px; margin-top: 10px; }
.bp button { line-height: 1.3; box-shadow: none; }
.bp-live { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.bp-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--rule2); border-radius: var(--r-lg); background: var(--paper); }
.bp-card .jp-row { border-top: 1px solid var(--rule); padding: 12px 0 0; }
.bp-card .jp-row-note { grid-column: 1 / -1; }
.bp-card .jp-row-note > span { min-width: 0; }
.bp-dim { color: var(--soft); }

/* who it is and how it stands */
.bp-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.bp-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); background: var(--solid); color: var(--on-solid); }
.bp-mark .icon { width: 18px; height: 18px; }
.bp-title { display: grid; gap: 1px; min-width: 0; }
.bp-title strong { font: 600 15px/1.3 var(--text); color: var(--ink); }
.bp-title span { font: 12px/1.4 var(--text); color: var(--soft); }
.bp-state { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border: 1px solid var(--rule2); border-radius: 999px; background: var(--canvas); color: var(--ink2); font: 600 11.5px/1.2 var(--text); white-space: nowrap; }
.bp-state .icon { width: 13px; height: 13px; }
.bp-state.s-subscription { border-color: color-mix(in srgb, var(--ok) 45%, var(--rule2)); color: var(--ok); }
.bp-state.s-reconnect, .bp-state.s-unavailable { border-color: color-mix(in srgb, var(--warn) 45%, var(--rule2)); color: var(--warn); }
.bp-state.s-connecting, .bp-state.s-identity_only { border-color: color-mix(in srgb, var(--info) 45%, var(--rule2)); color: var(--info); }
.bp-state.s-not_configured, .bp-state.s-disconnected { color: var(--soft); }
.bp-detail { margin: 0; font: 13px/1.55 var(--text); color: var(--ink2); max-width: 68ch; }
.bp-account, .bp-using { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; gap: 8px; margin: 0; font: 500 13px/1.4 var(--text); color: var(--ink); }
.bp-account .icon, .bp-using .icon { width: 15px; height: 15px; color: var(--muted); }
.bp-using > .icon-check { color: var(--ok); }
.bp-account { flex-wrap: nowrap; align-items: flex-start; }
.bp-account .icon { flex: none; margin-top: 2px; }
.bp-account > span { min-width: 0; overflow-wrap: anywhere; }
.bp-using .bp-link { margin-left: auto; }

/* the offer, the first-time note, the confirm */
.bp-offer, .bp-welcome, .bp-confirm { display: grid; gap: 8px; padding: 14px; border-radius: var(--r); background: var(--canvas); }
.bp-offer strong, .bp-welcome strong { font: 600 13.5px/1.3 var(--text); color: var(--ink); }
.bp-offer p, .bp-welcome p, .bp-confirm p { margin: 0; font: 12.5px/1.55 var(--text); color: var(--soft); max-width: 66ch; }
.bp-welcome { border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--rule2)); justify-items: start; }
.bp-confirm { border: 1px solid color-mix(in srgb, var(--stop) 35%, var(--rule2)); }
.bp-confirm p { color: var(--ink2); }
.bp-needs { margin: 0; padding: 0 0 0 18px; display: grid; gap: 6px; font: 12.5px/1.55 var(--text); color: var(--soft); max-width: 70ch; }

.bp-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bp-actions .jp-set-action { min-height: 36px; }
.bp-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px; border: 1px solid var(--primary-line); border-radius: 999px; background: var(--primary-bg); color: var(--primary-fg); font: 600 13px var(--text); text-decoration: none; cursor: pointer; }
.bp-primary:hover { background: var(--primary-bg-hover); color: var(--primary-fg); }
.bp-primary:disabled { opacity: .55; cursor: default; }
.bp-link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent3); font: 600 12.5px var(--text); text-decoration: underline; text-underline-offset: 3px; }
.bp-link .icon { width: 12px; height: 12px; color: currentColor; }
.bp :is(button, a, select, input):focus-visible { outline: 2px solid var(--accent3); outline-offset: 2px; }

/* fallback and its cap */
.bp-group { display: grid; gap: 12px; }
.bp-cap-wrap { display: inline-flex; align-items: center; gap: 4px; font: 500 13px var(--text); color: var(--soft); }
.bp-cap { width: 84px; min-height: 36px; padding: 6px 8px; border-radius: var(--r-sm); font: 500 13.5px var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.bp-cap:disabled { opacity: .55; }

/* usage through Bleed */
.bp-usage { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--rule); }
.bp-usage-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
.bp-usage-head strong { font: 600 13.5px/1.3 var(--text); }
.bp-usage p { margin: 0; font: 12px/1.5 var(--text); max-width: 70ch; }
.bp-table-wrap { overflow-x: auto; }
.bp-table { width: 100%; border-collapse: collapse; font: 12.5px/1.4 var(--text); font-variant-numeric: tabular-nums; }
.bp-table :is(th, td) { padding: 7px 0 7px 12px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: right; text-transform: none; letter-spacing: 0; white-space: nowrap; font: inherit; color: var(--ink2); }
.bp-table :is(th, td):first-child { min-width: 150px; padding-left: 0; text-align: left; white-space: normal; }
.bp-table thead th { font: 600 11px/1.3 var(--text); color: var(--muted); }
.bp-table tbody th span { display: block; }
.bp-table tbody th .bp-model { font-weight: 500; color: var(--ink); overflow-wrap: break-word; }
.bp-table tbody th .bp-dim { font-size: 11.5px; }
.bp-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.bp label.jp-row-text { cursor: default; }
.bp label.jp-row-text strong { color: var(--ink); }

.bp-offer .bp-quiet { color: var(--muted); }
.bp-said { margin: 0; padding: 10px 12px; border: 1px dashed var(--rule2); border-radius: var(--r); font: 12px/1.5 var(--mono); color: var(--ink2); overflow-wrap: anywhere; }
.bp-said .bp-dim { font-family: var(--text); }

/* the chat box's model picker: a quiet pill in the composer's tool row, its menu above it */
.bpk { position: relative; display: inline-flex; min-width: 0; }
.bpk-btn { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: min(320px, 78vw); min-height: 30px; padding: 0 10px; border: 1px solid var(--rule2); border-radius: 999px; background: var(--paper); color: var(--ink2); font: 600 12px/1.2 var(--text); box-shadow: none; cursor: pointer; }
.bpk-btn:hover, .bpk-btn[aria-expanded="true"] { border-color: var(--gold-line); background: var(--accent2); color: var(--accent3); }
.bpk-btn:disabled { opacity: .7; cursor: default; background: var(--paper); border-color: var(--rule2); color: var(--ink2); }
.bpk-btn .icon { flex: none; width: 13px; height: 13px; color: var(--muted); }
.bpk-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bpk-fund { flex: none; font-weight: 500; color: var(--soft); white-space: nowrap; }
.bpk-fund:not(:empty)::before { content: "·"; margin-right: 6px; color: var(--muted); }
.bpk-menu { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 60; display: grid; gap: 2px; width: min(340px, calc(100vw - 32px)); max-height: min(60vh, 440px); overflow-y: auto; padding: 8px; border: 1px solid var(--rule2); border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--shadow); }
.bpk-menu[hidden] { display: none; }
.bpk-group { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0; padding: 6px 8px 4px; font: 600 11px/1.3 var(--text); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.bpk-group span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; letter-spacing: 0; text-transform: none; }
.bpk-item { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; min-height: 36px; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: 500 13px/1.3 var(--text); text-align: left; box-shadow: none; cursor: pointer; }
.bpk-item:hover, .bpk-item:focus-visible { background: var(--accent2); color: var(--accent3); }
.bpk-item[aria-disabled="true"], .bpk-item[aria-disabled="true"]:hover { background: transparent; color: var(--muted); cursor: default; }
.bpk-tick { display: grid; place-items: center; }
.bpk-tick .icon { width: 14px; height: 14px; }
.bpk-item[role="menuitemradio"] .bpk-tick .icon { visibility: hidden; color: var(--ok); }
.bpk-item[aria-checked="true"] .bpk-tick .icon { visibility: visible; }
.bpk-item[aria-checked="true"] .bpk-name { font-weight: 650; }
.bpk-name { min-width: 0; overflow-wrap: anywhere; }
.bpk-hint { font: 11.5px/1.3 var(--text); color: var(--soft); white-space: nowrap; }
.bpk-item.quiet { color: var(--soft); }
.bpk-item.quiet .icon { color: var(--muted); }
.bpk-note { margin: 0; padding: 4px 8px 6px; font: 12px/1.45 var(--text); color: var(--soft); }
.bpk-note.warn { color: var(--warn); }
.bpk-rule { margin: 6px 0; border: 0; border-top: 1px solid var(--rule); }

@media (max-width: 560px) {
  .bp-card { padding: 14px; }
  .bp-head { grid-template-columns: auto minmax(0, 1fr); }
  .bp-state { grid-column: 1 / -1; justify-self: start; }
  .bp-using .bp-link { margin-left: 0; }
}
