/* ── Component: ToolSettings modal, tool assignment and setup ──
 * Class prefix: tools- (tools-overlay, tools-modal, etc.)
 */

/* ── Tool Settings Panel ────────────────────────────────── */

.tools-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.tools-modal {
  background: rgba(15, 15, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.tools-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.tools-modal-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.tools-modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
}
.tools-modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tools-modal-body {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  flex: 1;
  padding: 1rem 1.5rem 1.5rem;
}

/* Server status bar */
.tools-server-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.75rem;
  margin-bottom: 1.25rem;
}

.tools-server-chip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 100px;
  cursor: default;
  border: 1px solid transparent;
}

.tools-server-chip.connected {
  background: rgba(52, 199, 89, 0.12);
  border-color: rgba(52, 199, 89, 0.3);
  color: #34c759;
}

.tools-server-chip.disconnected {
  background: rgba(255, 59, 48, 0.1);
  border-color: rgba(255, 59, 48, 0.25);
  color: rgba(255, 100, 90, 0.9);
}

.tools-server-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.connected .tools-server-dot { background: #34c759; }
.disconnected .tools-server-dot { background: #ff3b30; }

/* Mini rows */
.tools-mini-row {
  margin-bottom: 1.25rem;
}

.tools-mini-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

.tools-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.tools-mini-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.tools-mini-role {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
}

.tools-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-left: 2.375rem;
}

.tools-chip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.625rem;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
  transition: background 0.15s, border-color 0.15s;
}

.tools-chip.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
  color: rgba(160, 163, 255, 0.95);
}

.tools-chip-remove {
  background: none;
  border: none;
  color: rgba(255, 100, 90, 0.7);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-left: 0.125rem;
  transition: color 0.15s;
}
.tools-chip-remove:hover { color: #ff3b30; }

/* Setup required badge */
.tools-chip.setup-required {
  background: rgba(255, 149, 0, 0.1);
  border-color: rgba(255, 149, 0, 0.3);
  color: rgba(255, 180, 60, 0.9);
}

/* Add tool button */
.tools-add-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.625rem;
  border-radius: 100px;
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.15s;
}
.tools-add-btn:hover {
  border-color: rgba(99, 102, 241, 0.5);
  color: rgba(160, 163, 255, 0.9);
  background: rgba(99, 102, 241, 0.1);
}

/* Add tool dropdown */
.tools-add-dropdown {
  position: relative;
  display: inline-flex;
}

.tools-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: rgba(20, 20, 40, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  min-width: 200px;
  z-index: 400;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: none;
}
.tools-add-menu.open { display: block; }

.tools-add-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}
.tools-add-menu-item:hover { background: rgba(99, 102, 241, 0.15); color: #fff; }
.tools-add-menu-item.disabled { opacity: 0.4; cursor: default; pointer-events: none; }

.tools-add-menu-item-icon { font-size: 0.9rem; }
.tools-add-menu-item-name { flex: 1; font-weight: 500; }
.tools-add-menu-item-status {
  font-size: 0.65rem;
  color: rgba(255, 180, 60, 0.8);
  font-weight: 500;
}

.tools-mini-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin: 1rem 0;
}

.tools-empty-mini {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  padding-left: 2.375rem;
}

/* Loading / error states */
.tools-loading {
  text-align: center;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

/* ── Tab bar ── */
.tools-tab-bar {
  display: flex;
  gap: 2px;
  padding: 8px 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.tools-tab {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.tools-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.tools-tab--active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ── Add menu category headers ── */
.tools-add-menu-cat {
  padding: 6px 12px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 2px;
}
.tools-add-menu-cat:first-child {
  border-top: none;
  margin-top: 0;
}

/* ── Setup tab ── */
.tools-setup-section {
  margin-bottom: 1.25rem;
}
.tools-setup-cat-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.625rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.tools-setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.625rem;
}

/* Setup card */
.tools-setup-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s;
}
.tools-setup-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}
.tools-setup-card.configured {
  border-color: rgba(52, 199, 89, 0.25);
}
.tools-setup-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tools-setup-card-icon {
  font-size: 1.1rem;
}
.tools-setup-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  flex: 1;
}
.tools-setup-card-desc {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.4;
}
.tools-setup-card-note {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}
.tools-setup-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(255, 149, 0, 0.12);
  color: rgba(255, 180, 60, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.tools-setup-badge--ok {
  background: rgba(52, 199, 89, 0.12);
  color: #34c759;
}
.tools-setup-btn {
  padding: 6px 12px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: rgba(160, 163, 255, 0.95);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  align-self: flex-start;
  margin-top: 2px;
}
.tools-setup-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
}

/* ── Config modal ── */
.tools-config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.tools-config-modal {
  background: rgba(18, 18, 35, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.tools-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.tools-config-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}
.tools-config-info {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 16px;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Setup guide (collapsible) ── */
.tools-guide {
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
.tools-guide-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: rgba(160, 163, 255, 0.9);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.tools-guide-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}
.tools-guide-arrow {
  font-size: 0.6rem;
  transition: transform 0.2s;
  display: inline-block;
}
.tools-guide.open .tools-guide-arrow {
  transform: rotate(90deg);
}
.tools-guide-body {
  display: none;
  padding: 0 14px 14px;
}
.tools-guide.open .tools-guide-body {
  display: block;
  animation: tools-reveal 0.2s ease;
}
.tools-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: rgba(160, 163, 255, 0.95);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 10px;
  transition: background 0.15s, border-color 0.15s;
}
.tools-guide-link:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
}
.tools-guide-link::before {
  content: '\2197';
  font-size: 0.85rem;
}
.tools-guide-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tools-guide-steps li {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
}
.tools-guide-steps li::marker {
  color: rgba(160, 163, 255, 0.6);
  font-weight: 600;
}

.tools-config-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}
.tools-config-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}
.tools-config-hint {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.7rem;
}
.tools-config-input-wrap {
  position: relative;
}
.tools-config-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-primary, #fff);
  font-size: 0.875rem;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  transition: border-color 0.15s;
}
.tools-config-input:focus {
  border-color: rgba(99, 102, 241, 0.6);
}
.tools-config-input-wrap .tools-config-input {
  padding-right: 40px;
}
.tools-config-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.4);
  padding: 6px;
  font-size: 0.85rem;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tools-config-error {
  font-size: 0.78rem;
  color: #ef4444;
  min-height: 0;
}
.tools-config-error:not(:empty) {
  padding: 6px 10px;
  background: rgba(239, 68, 68, 0.08);
  border-radius: 6px;
  margin-bottom: 8px;
}
.tools-config-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.tools-config-save {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #6C3BEE, #a78bfa);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.tools-config-save:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tools-config-save:not(:disabled):hover {
  opacity: 0.9;
}
.tools-config-delete {
  padding: 8px 16px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.tools-config-delete:hover {
  background: rgba(239, 68, 68, 0.15);
}
.tools-config-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Test Connection button (API tools) */
.tools-config-test {
  padding: 8px 16px;
  border: 1px solid rgba(52, 199, 89, 0.35);
  border-radius: 8px;
  background: rgba(52, 199, 89, 0.08);
  color: #34c759;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tools-config-test:hover {
  background: rgba(52, 199, 89, 0.18);
  border-color: rgba(52, 199, 89, 0.5);
}
.tools-config-test:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── HeyGen avatar/voice picker ────────────────────────── */

.heygen-picker {
  margin-top: 4px;
}

.heygen-load-btn {
  padding: 8px 16px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.12);
  color: rgba(160, 163, 255, 0.95);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
}
.heygen-load-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
}
.heygen-load-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.heygen-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  margin: 14px 0 8px;
}

.heygen-avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding: 2px;
}

.heygen-avatar-card {
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.heygen-avatar-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}
.heygen-avatar-card.selected {
  border-color: #a78bfa;
  background: rgba(167, 139, 250, 0.08);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.15);
}

.heygen-avatar-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}
.heygen-avatar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.heygen-avatar-play {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}
.heygen-avatar-play:hover {
  background: rgba(99, 102, 241, 0.7);
}

.heygen-avatar-name {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.heygen-avatar-gender {
  font-size: 0.58rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.heygen-voice-group {
  margin-top: 4px;
}

.heygen-voice-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.heygen-voice-select option {
  background: #1a1a2e;
  color: #fff;
}

.heygen-picker-empty {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.4);
  padding: 12px;
  text-align: center;
}

@media (max-width: 480px) {
  .heygen-avatar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── MiniCard tool chips strip ──────────────────────────── */

.mini-card-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  border-radius: 6px;
  padding: 3px 2px;
  transition: background 0.15s;
}

.mini-card-tools:hover {
  background: rgba(255, 255, 255, 0.04);
}

.mini-card-tools-label {
  font-size: 8px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 2px;
}

.mini-card-tool-chip {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 100px;
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(99, 102, 241, 0.20);
  color: rgba(160, 163, 255, 0.85);
  white-space: nowrap;
}

/* ── MiniSelector inline tool section ───────────────────── */

.ms-tools-section {
  flex-basis: 100%;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  /* indent past accent + gap + avatar + gap */
  padding: 10px 14px 12px 79px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
}

.ms-tools-section.visible {
  display: flex;
  animation: tools-reveal 0.25s ease both;
}

@keyframes tools-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ms-tools-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.ms-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.ms-tool-chip:hover {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.ms-tool-chip:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

.ms-tool-chip.active {
  background: rgba(108, 59, 238, 0.18);
  border-color: rgba(108, 59, 238, 0.45);
  color: rgba(180, 160, 255, 0.95);
}

.ms-tool-chip.active:hover {
  background: rgba(220, 50, 50, 0.15);
  border-color: rgba(220, 50, 50, 0.4);
  color: rgba(255, 120, 120, 0.9);
}

.ms-tool-chip.unconfigured {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
  border-style: dashed;
}

@media (prefers-reduced-motion: reduce) {
  .ms-tools-section.visible {
    animation: none;
  }
  .ms-tool-chip {
    transition: none;
  }
}

/* ── Touch targets + bottom sheet ── */
@media (hover: none) and (pointer: coarse) {
  .tools-chip,
  .tools-add-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
  }
}

@media (max-width: 768px) {
  .tools-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .tools-modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    max-height: 92dvh;
  }

  .tools-modal-body {
    padding-bottom: calc(1.5rem + var(--safe-bottom, 0px));
  }
}

/* ═══════════════════════════════════════════════════════════
   TOOL ASSIGN — Two-panel layout (mini nav + tool panel)
═══════════════════════════════════════════════════════════ */

.tools-assign-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 0 !important;
  min-height: 0;
}

/* ── Mini nav (desktop sidebar) ── */
.ta-mini-nav {
  width: 170px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  overflow-y: auto;
  padding: 6px 0;
}

.ta-mini-nav-label {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  padding: 8px 14px 5px;
}

.ta-mn-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-left: 2px solid transparent;
}

.ta-mn-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ta-mn-item.active {
  background: rgba(255, 255, 255, 0.04);
  border-left-color: #fff;
}

.ta-mn-av {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.ta-mn-info {
  flex: 1;
  min-width: 0;
}

.ta-mn-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ta-mn-item.active .ta-mn-name {
  color: #fff;
}

.ta-mn-role {
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ta-mn-warn {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FBBF24;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Mobile mini chips (hidden on desktop) ── */
.ta-mobile-chips {
  display: none;
}

/* ── Right panel ── */
.ta-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panel header */
.ta-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.ta-ph-av {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.ta-ph-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.ta-ph-sub {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 1px;
}

.ta-btn-ghost {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  transition: all 0.15s;
  font-family: inherit;
}

.ta-btn-ghost:hover {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Summary bar */
.ta-summary-bar {
  display: flex;
  gap: 8px;
  padding: 8px 20px;
  flex-shrink: 0;
}

.ta-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
}

.ta-summary-pill.ready {
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: #4ADE80;
}

.ta-summary-pill.warn {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: #FBBF24;
}

/* Panel scroll area */
.ta-panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
}

.ta-panel-scroll::-webkit-scrollbar {
  width: 3px;
}

.ta-panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Category labels */
.ta-tg-label {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin: 12px 0 6px;
}

.ta-tg-label:first-child {
  margin-top: 0;
}

/* Tool list items */
.ta-tool-list {
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 2px;
}

.ta-tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.12s;
}

.ta-tool-item:last-child {
  border-bottom: none;
}

.ta-tool-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ta-ti-icon {
  font-size: 0.88rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.ta-ti-name {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.ta-ti-status-ok {
  font-size: 0.65rem;
  color: #4ADE80;
  margin-left: auto;
}

.ta-ti-warn {
  font-size: 0.62rem;
  color: #FBBF24;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.18);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: auto;
}

.ta-ti-setup-btn {
  font-size: 0.62rem;
  font-weight: 600;
  font-family: inherit;
  color: #FBBF24;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.18);
  border-radius: 4px;
  padding: 2px 8px;
  margin-left: auto;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.ta-ti-setup-btn:hover {
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.4);
  color: #FCD34D;
}

.ta-ti-rm {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  transition: all 0.12s;
  margin-left: 2px;
  padding: 0;
  font-family: inherit;
  opacity: 0;
}

.ta-tool-item:hover .ta-ti-rm {
  opacity: 1;
}

.ta-ti-rm:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.2);
  color: #F87171;
}

/* Empty state */
.ta-empty {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  padding: 20px 0;
  text-align: center;
}

/* ── Add tool CTA row ── */
.ta-add-tool-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: transparent;
  border: 1.5px dashed rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 10px;
}

.ta-add-tool-row:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.02);
}

.ta-at-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.88rem;
  flex-shrink: 0;
}

.ta-at-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

.ta-at-sub {
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 1px;
}

.ta-at-arrow {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
}

/* ═══ PICKER PANEL (slide-in state) ═══ */

.ta-picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.ta-back-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: all 0.12s;
}

.ta-back-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.2);
}

.ta-picker-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

.ta-picker-sub {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 1px;
}

/* Picker search */
.ta-picker-search {
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.ta-search-wrap {
  position: relative;
}

.ta-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  stroke: rgba(255, 255, 255, 0.2);
  fill: none;
}

.ta-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 7px 12px 7px 32px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  outline: none;
  font-family: inherit;
}

.ta-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.ta-search-input:focus {
  border-color: rgba(255, 255, 255, 0.25);
}

/* Picker scroll */
.ta-picker-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 16px;
}

.ta-picker-scroll::-webkit-scrollbar {
  width: 3px;
}

.ta-picker-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Available tool list */
.ta-avail-list {
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 2px;
}

.ta-avail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.12s;
}

.ta-avail-item:last-child {
  border-bottom: none;
}

.ta-avail-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ta-avail-item.already {
  opacity: 0.45;
}

.ta-ai-icon {
  font-size: 0.88rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.ta-ai-name {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.ta-ai-warn {
  font-size: 0.56rem;
  color: #FBBF24;
  display: flex;
  align-items: center;
  gap: 3px;
}

.ta-ai-warn::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FBBF24;
  flex-shrink: 0;
}

.ta-ai-added {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.6);
  margin-left: 8px;
}

/* Add button */
.ta-btn-add {
  padding: 4px 12px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.13);
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  white-space: nowrap;
  margin-left: 8px;
}

.ta-btn-add:hover {
  border-color: #fff;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.ta-btn-add.added {
  border-color: rgba(74, 222, 128, 0.25);
  color: #4ADE80;
  background: rgba(74, 222, 128, 0.06);
  cursor: default;
}

/* ═══ MOBILE BOTTOM SHEET ═══ */

.ta-bs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.ta-bottom-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 75vh;
  background: rgba(15, 15, 30, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.ta-bottom-sheet.open {
  transform: translateY(0);
}

.ta-bs-handle {
  width: 32px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  margin: 10px auto 0;
}

.ta-bs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
}

.ta-bs-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
}

.ta-bs-sub {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.ta-bs-close {
  font-size: 1.12rem;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 2px 6px;
}

/* Bottom sheet search */
.ta-bs-search {
  padding: 0 14px 10px;
}

.ta-bs-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 7px 12px 7px 30px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  outline: none;
  font-family: inherit;
}

.ta-bs-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Category filter chips */
.ta-bs-cat-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 14px 10px;
}

.ta-bs-cat-row::-webkit-scrollbar {
  display: none;
}

.ta-bs-cat {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.12s;
}

.ta-bs-cat.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Bottom sheet tool list */
.ta-bs-list {
  padding: 0 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  flex: 1;
}

.ta-bs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  transition: background 0.12s;
}

.ta-bs-icon {
  font-size: 0.94rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.ta-bs-info {
  flex: 1;
  min-width: 0;
}

.ta-bs-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.ta-bs-status {
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 1px;
}

.ta-bs-status.warn {
  color: #FBBF24;
}

.ta-bs-add-btn {
  padding: 5px 12px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.13);
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.12s;
}

.ta-bs-add-btn:hover {
  border-color: #fff;
  color: #fff;
}

.ta-bs-add-btn.added {
  border-color: rgba(74, 222, 128, 0.25);
  color: #4ADE80;
  background: rgba(74, 222, 128, 0.06);
  cursor: default;
}

/* ═══ MOBILE RESPONSIVE ═══ */
@media (max-width: 768px) {
  .tools-assign-body {
    flex-direction: column;
    padding: 0;
  }

  /* Hide desktop mini nav on mobile */
  .ta-mini-nav {
    display: none;
  }

  /* Show mobile chips */
  .ta-mobile-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 12px 14px 2px;
    flex-shrink: 0;
  }

  .ta-mobile-chips::-webkit-scrollbar {
    display: none;
  }

  .ta-m-chip {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px 6px 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
  }

  .ta-m-chip.active {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
  }

  .ta-m-chip-av {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.56rem;
    font-weight: 700;
    color: #fff;
  }

  .ta-m-chip-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
  }

  .ta-m-chip.active .ta-m-chip-name {
    color: #fff;
  }

  .ta-m-chip-warn {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #FBBF24;
    flex-shrink: 0;
  }

  .ta-panel {
    flex: 1;
    overflow: hidden;
  }

  .ta-panel-head {
    padding: 10px 14px;
  }

  .ta-panel-scroll,
  .ta-picker-scroll {
    padding: 10px 14px;
  }

  .ta-picker-head {
    padding: 10px 14px;
  }

  .ta-picker-search {
    padding: 8px 14px;
  }
}

/* Expand modal width on desktop for two-panel layout */
@media (min-width: 769px) {
  .tools-modal.tools-modal--wide {
    max-width: 780px;
  }

  .ta-mobile-chips {
    display: none;
  }
}
