.ub-agent-header-button {
  display: inline-grid;
  box-sizing: border-box;
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  place-items: center;
  padding: 0;
  border-color: rgba(103, 198, 255, .62);
  border-radius: 8px;
  background: linear-gradient(145deg, #173f68, #10263e);
  color: #dff4ff;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .04em;
}
.ub-agent-header-button[hidden] { display: none; }
.ub-agent-header-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ub-agent-modal { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; box-sizing: border-box; padding: 1rem; }
.ub-agent-modal[hidden] { display: none; }
.ub-agent-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 7, 15, .78); backdrop-filter: blur(5px); }
.ub-agent-modal-dialog { position: relative; z-index: 1; box-sizing: border-box; width: min(760px, 100%); max-height: min(88vh, 860px); overflow-y: auto; border: 1px solid rgba(106, 167, 220, .52); border-radius: 14px; background: #071b2c; box-shadow: 0 28px 90px rgba(0, 0, 0, .58); }
.ub-agent-modal-toolbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .75rem 1rem; border-bottom: 1px solid rgba(129, 192, 246, .24); background: rgba(7, 27, 44, .98); }
.ub-agent-modal-toolbar h2 { margin: 0; font-size: 1rem; }
.ub-agent-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.ub-agent-ready-state { display: grid; justify-items: center; gap: .55rem; padding: 2rem 1rem 2.25rem; text-align: center; }
.ub-agent-ready-state h3, .ub-agent-ready-state p { margin: 0; }
.ub-agent-ready-state p { max-width: 560px; color: #a8bfd5; line-height: 1.55; }
.ub-agent-ready-icon { display: grid; width: 58px; height: 58px; place-items: center; border: 1px solid rgba(103, 198, 255, .62); border-radius: 12px; background: linear-gradient(145deg, #173f68, #10263e); color: #dff4ff; font-size: 1rem; font-weight: 900; }
.ub-agent-ready-action { min-height: 44px; border-color: #4ea7f4; background: linear-gradient(135deg, #1683ff, #0a57c9); color: #fff; }

.ub-agent-panel {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 1rem;
  overflow: hidden;
  border: 1px solid rgba(106, 167, 220, .42);
  border-top: 4px solid #55b9ff;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(145deg, rgba(6, 22, 38, .98), rgba(12, 42, 67, .96));
  box-shadow: 0 18px 45px rgba(0, 0, 0, .24);
}

.ub-agent-header { display: flex; align-items: flex-start; gap: .85rem; }
.ub-agent-avatar-wrap { flex: 0 0 64px; width: 64px; height: 64px; overflow: hidden; border: 1px solid rgba(129, 192, 246, .42); border-radius: 9px; background: #112f4c; }
.ub-agent-avatar { display: block; width: 100%; height: 100%; object-fit: cover; }
.ub-agent-header-content { display: grid; min-width: 0; gap: .25rem; }
.ub-agent-badge { width: fit-content; padding: .2rem .48rem; border: 1px solid rgba(102, 204, 255, .5); border-radius: 999px; background: rgba(22, 131, 255, .2); color: #bfe8ff; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.ub-agent-name { overflow-wrap: anywhere; }
.ub-agent-description { margin: 0; color: #bad0e3; line-height: 1.5; overflow-wrap: anywhere; }
.ub-agent-status { color: #a8bfd5; font-size: .78rem; font-weight: 700; text-transform: capitalize; }
.ub-agent-status[data-status="online"] { color: #85e0ae; }
.ub-agent-status[data-status="busy"] { color: #ffd27a; }
.ub-agent-identity { display: grid; gap: .55rem; margin-top: .8rem; padding: .7rem; border: 1px solid rgba(129, 192, 246, .28); border-radius: 9px; background: rgba(5, 24, 41, .58); }
.ub-agent-identity-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem; }
.ub-agent-verification { padding: .2rem .45rem; border: 1px solid rgba(255, 202, 112, .45); border-radius: 999px; color: #ffd27a; font-size: .68rem; font-weight: 800; }
.ub-agent-verification[data-status="attested"] { border-color: rgba(92, 221, 151, .52); color: #85e0ae; }
.ub-agent-identity-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .25rem .55rem; margin: 0; font-size: .76rem; }
.ub-agent-identity-details dt { color: #8dabc5; font-weight: 800; }
.ub-agent-identity-details dd { min-width: 0; margin: 0; color: #d7eaff; overflow-wrap: anywhere; }
.ub-agent-service-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.ub-agent-service-link { padding: .3rem .52rem; border: 1px solid rgba(102, 204, 255, .38); border-radius: 7px; color: #bfe8ff; font-size: .72rem; font-weight: 800; }
.ub-agent-verification-note { margin: 0; color: #9db5ca; font-size: .72rem; line-height: 1.45; }
.ub-agent-capabilities, .ub-agent-suggestions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.ub-agent-capability { padding: .25rem .5rem; border: 1px solid rgba(129, 192, 246, .3); border-radius: 999px; background: rgba(20, 76, 123, .22); color: #c8e7ff; font-size: .72rem; }
.ub-agent-suggestion { min-height: 38px; padding: .42rem .62rem; border-radius: 8px; background: rgba(16, 42, 69, .9); text-align: left; white-space: normal; }
.ub-agent-messages { display: grid; gap: .55rem; max-height: 360px; margin-top: .9rem; padding: .75rem; overflow-y: auto; border: 1px solid rgba(123, 173, 214, .22); border-radius: 10px; background: rgba(2, 12, 22, .65); }
.ub-agent-message { width: fit-content; max-width: min(88%, 680px); padding: .55rem .68rem; border-radius: 10px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.ub-agent-message-user { justify-self: end; background: #155c94; color: #fff; }
.ub-agent-message-assistant { justify-self: start; background: #132d46; color: #e8f5ff; }
.ub-agent-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; align-items: end; margin-top: .65rem; }
.ub-agent-input { width: 100%; min-width: 0; max-height: 180px; resize: vertical; }
.ub-agent-send { min-width: 88px; min-height: 44px; border-color: #4ea7f4; background: linear-gradient(135deg, #1683ff, #0a57c9); color: #fff; }
.ub-agent-loading, .ub-agent-connection-note { margin: .65rem 0 0; color: #a8bfd5; }
.ub-agent-error { margin: .65rem 0 0; color: #ffb5c7; overflow-wrap: anywhere; }
.ub-agent-message-owner { margin-top: .65rem; }
.ub-agent-selected-item { outline: 3px solid #55b9ff; outline-offset: 3px; }
.ub-agent-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.ub-agent-settings { display: grid; gap: .75rem; margin-top: .75rem; padding: .85rem; border: 1px solid rgba(95, 183, 242, .34); border-radius: 10px; background: rgba(12, 48, 77, .2); }
.ub-agent-settings-heading { display: grid; gap: .2rem; }
.ub-agent-settings-kicker { margin: 0; color: #8dcbff; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.ub-agent-settings-help { margin: 0; color: #a8bfd5; line-height: 1.5; }
.ub-agent-profile-identity-link { width: fit-content; color: #8dcbff; font-size: .82rem; font-weight: 800; text-underline-offset: 3px; }
.ub-agent-profile-identity-link:focus-visible { outline: 2px solid #8dcbff; outline-offset: 3px; border-radius: 3px; }
.ub-agent-standard-settings { display: grid; gap: .65rem; margin: 0; padding: .75rem; border: 1px solid rgba(129, 192, 246, .26); border-radius: 9px; }
.ub-agent-standard-settings legend { padding: 0 .35rem; color: #c8e7ff; font-weight: 800; }
.ub-agent-standard-link { color: #8dcbff; font-weight: 800; text-underline-offset: 3px; }
.ub-agent-setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.ub-agent-setting-field { display: grid; min-width: 0; gap: .34rem; color: #c9dff1; font-size: .82rem; font-weight: 700; }
.ub-agent-setting-field input, .ub-agent-setting-field textarea, .ub-agent-setting-field select { width: 100%; min-width: 0; }
.ub-agent-setting-toggle { display: inline-flex; align-items: center; gap: .48rem; color: #d7eaff; font-weight: 700; }
.ub-agent-setting-toggle input { width: 1.1rem; height: 1.1rem; }
.ub-agent-action-settings { min-width: 0; margin: .1rem 0 0; padding: .85rem; border: 1px solid rgba(129, 192, 246, .3); border-radius: 9px; background: rgba(7, 25, 41, .34); }
.ub-agent-action-settings legend { padding: 0 .4rem; color: #d7ebfb; font-size: .9rem; font-weight: 800; }
.ub-agent-action-settings-help { margin: 0 0 .7rem; color: #9fb9cf; font-size: .78rem; line-height: 1.5; text-wrap: pretty; }
.ub-agent-action-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.ub-agent-action-option { display: grid; grid-template-columns: 20px minmax(0, 1fr); min-width: 0; min-height: 44px; align-items: center; gap: .6rem; padding: .55rem .65rem; border: 1px solid rgba(129, 192, 246, .2); border-radius: 7px; background: rgba(16, 51, 79, .42); color: #d3e6f5; cursor: pointer; transition: border-color 150ms ease-out, background-color 150ms ease-out, box-shadow 150ms ease-out; }
.ub-agent-action-option:hover { border-color: rgba(129, 192, 246, .48); background: rgba(24, 69, 104, .5); }
.ub-agent-action-option:focus-within { border-color: #75bcf7; box-shadow: 0 0 0 2px rgba(117, 188, 247, .22); }
.ub-agent-action-option:has(input:checked) { border-color: rgba(78, 167, 244, .66); background: rgba(27, 92, 143, .4); }
.ub-agent-action-option input { width: 18px; height: 18px; margin: 0; accent-color: #4ea7f4; justify-self: center; }
.ub-agent-action-option span { min-width: 0; font-size: .8rem; font-weight: 700; line-height: 1.3; text-wrap: pretty; }

@media (max-width: 780px) {
  .ub-agent-header-button { flex-basis: 40px; width: 40px; min-width: 40px; max-width: 40px; height: 40px; min-height: 40px; max-height: 40px; }
  .ub-agent-modal { padding: 0; align-items: end; }
  .ub-agent-modal-dialog { width: 100%; max-height: 94vh; border-radius: 14px 14px 0 0; }
  .ub-agent-modal-toolbar { padding: .65rem .75rem; }
  .ub-agent-panel { margin: 0; padding: .8rem; border-radius: 0; }
  .ub-agent-header { gap: .65rem; }
  .ub-agent-avatar-wrap { flex-basis: 52px; width: 52px; height: 52px; }
  .ub-agent-messages { max-height: 42vh; }
  .ub-agent-form { grid-template-columns: minmax(0, 1fr); }
  .ub-agent-send { width: 100%; }
  .ub-agent-setting-grid, .ub-agent-action-settings-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .ub-agent-selected-item { scroll-behavior: auto; }
}
