/* ── Modal overlay ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

/* ── Generic modal ── */
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 20px;
  width: min(480px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-title {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--green-dim);
}

.modal-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 3px;
  resize: vertical;
  min-height: 100px;
  outline: none;
  line-height: 1.55;
}

.modal-textarea:focus { border-color: var(--green-dim); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.modal-btn:hover {
  background: var(--border);
  color: var(--text);
}

.modal-btn.primary {
  border-color: var(--green-dim);
  color: var(--green-dim);
}

.modal-btn.primary:hover {
  background: var(--green-dark);
  color: var(--green);
}

/* ── Agent selector modal ── */
.agent-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 20px;
  width: min(620px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0;
}

@media (max-width: 500px) {
  .agent-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.agent-card {
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 4px;
  text-align: center;
  background: var(--bg);
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
}

.agent-card:hover {
  border-color: var(--green-dim);
  background: var(--green-dark);
}

.agent-card.selected {
  border-color: var(--green-dim);
  background: var(--green-dark);
  box-shadow: 0 0 8px rgba(0, 179, 44, 0.2);
}

.agent-card-name,
.agent-card-role {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
}

.agent-card-name {
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.02em;
  font-weight: bold;
  justify-content: flex-end;
  padding-bottom: 3px;
}

.agent-card-role {
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.03em;
  justify-content: flex-start;
  padding-top: 3px;
}

.agent-card .word {
  display: block;
  line-height: 1.25;
}

.agent-card .word.long {
  font-size: 9px;
  letter-spacing: 0.01em;
}

.agent-card.selected .agent-card-name { color: var(--green); }

.agent-card.selected .agent-card-role { color: var(--green-dim); }
